Skip to content

Category Archives: Dynamic Programming

Given a 2d array, arr[][] and a piece of the chocolate bar of dimension N × M, the task is to find the minimum possible sum… Read More
Given an array arr[] consisting of N integers, the task is to find the total number of unordered pairs (i, j) in the array such… Read More
Given a matrix mat[][] of dimensions N * M and a set of coordinates of cell coordinates[][] of size Q, the task is to find… Read More
Given a positive integer N, the task is to reduce N to 2 by performing the following operations minimum number of times: Operation 1: Divide… Read More
Given a binary string of size N, the task is to count the number of alternating substrings that are present in the string S. Examples: … Read More
Given an array A[] consisting of N non-negative integers, and an integer K, the task is to find the number of ways ‘+’ and ‘-‘… Read More
Given an array A[] of size N and an integer diff, the task is to count the number of ways to split the array into… Read More
Given two arrays A[] and B[] of sizes N, the task is to find the maximum sum of Bitwise AND of same-indexed elements in the… Read More
Given an integer N, the task is to count the number of N-digit numbers such that each digit, except the first and second digits, is… Read More
Given an integer N, the task to print the count numbers from the range [1, N] whose adjacent digits are not co-prime.  Two numbers A… Read More
Given an array arr[] of size N, denoting values assigned to N stones, two players, Player1 and Player2, play a game of alternating turns. In… Read More
Given N stations and three trains A, B, and C such that train A stops at every station, train B stops at every second station,… Read More
Given two numbers N and M, the task is to find the number of sorted arrays that can be formed of size M using first… Read More