Given an undirected tree with N nodes numbered from 1 to N and an array A[] where A[i] denotes the value assigned to (i+1)th node.… Read More

# Tag Archives: Memoization

Given an array arr[] of N strings, and Q queries where each of the queries contains some characters, the task is to check if for… Read More

Given two strings A and B of size N and M respectively, where B is a sub-sequence of A and an array arr[] of size… Read More

Given two integer arrays A[] and B[] of different length N and M respectively, the task is to choose any subsequence of same length from… Read More

Given two arrays arrA[] and arrB[] containing N integers each. Perform the following operation any number of times (possibly zero): Select any index i (0… Read More

Given two arrays a[] and b[] and an integer K, the task is to find the length of the longest common subsequence such that sum… Read More

Given a number N, the task is to count the combinations of K numbers from 1 to N having a sum equal to N, with… Read More

Given two arrays array[] and multipliers[] of size N and M where N is always greater than equal to M. There are M operations to… Read More

Given an array arr[] consisting of permutation of the first N natural numbers, the task is to find the expected number of swaps to sort… Read More

Given three integers N, M and P, the task is to find the total number of valid arrays that can be created of size P… Read More

Given an array A[] of size N, the task is to find the maximum score possible of this array. The score of an array is… Read More

Given a positive integer N, the task is to find the number of all N-digit numbers whose adjacent digits have equal Greatest Common Divisor(GCD). Examples:… Read More

Given an array arr[] consisting of N positive integers such that arr[i] denotes the size of the ith group sitting in a donut shop and… Read More

Given a number K, and N bars of height from 1 to N, the task is to find the number of ways to arrange the… Read More

Given an array arr[] consisting of N integers and an integer M (initially 1), the task is to find the maximum sum of array elements… Read More