Maximize sum of MEX values of each node in an N-ary Tree
Given an N-ary tree rooted at 1, the task is to assign values from the range [0, N – 1] to each node in any order such that the sum of MEX values of each node in the tree is maximized and print the maximum possible sum of MEX values of each node in the tree....
read more
Generate all distinct subsequences of array using backtracking
Given an array arr[] consisting of N positive integers, the task is to generate all distinct subsequences of the array....
read more
Print all Increasing Subsequence of a List
Given a list or array of integer, the task is to print all such subsequences of this list such in which the elements are arranged in increasing order.A Subsequence of the list is an ordered subset of that list’s element having same sequential ordering as the original list. Examples:...
read more
Print all subsequences of a string using ArrayList
Given a string str, the task is to print all the sub-sequences of str. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.Examples:...
read more
Sum of all subsets whose sum is a Perfect Number from a given array
Given an array arr[] consisting of N integers, the task is to find the sum of all subsets from an array, whose sum is a Perfect Number....
read more
Transform N to Minimum possible value
Given two numbers and N and D. Apply any of two below operations to N:...
read more
Why Recursive Function returns “Undefined”?
In simple words, recursion is when a function is calling itself directly or indirectly....
read more
Pair with given Sum (Two Sum)
Given an array A[] of n numbers and another number x, the task is to check whether or not there exist two elements in A[] whose sum is exactly x....
read more
Maximize sum by selecting X different-indexed elements from three given arrays
Given three arrays A[], B[] and C[] of size N and three positive integers X, Y, and Z, the task is to find the maximum sum possible by selecting at most N array elements such that at most X elements are from the array A[], at most Y elements from the array B[], at most Z elements are from the array C[] and all elements are from different indices....
read more
Length of longest common prime subsequence from two given arrays
Given two arrays arr1[] and arr2[] of length N and M respectively, the task is to find the length of the longest common prime subsequence that can be obtained from the two given arrays....
read more
Print all paths of the Binary Tree with maximum element in each path greater than or equal to K
Given a binary tree and an integer K, the task is to print the paths from root to leaf with the maximum element greater than or equal to K. Print -1 if there exists no such path.Examples:...
read more
Count of integers in range [L, R] having even frequency of each digit
Given two integers L and R, the task is to find the count of integers in the range [L, R] such that the frequency of each digit in the integer is even....
read more