Category Archives: Recursion

Given an array arr[] consisting of N integers and an integer K, the task is to count the number of subsequences of the given array… Read More
Given an array arr[] of N non-negative integers and an integer K, the idea is to find the length of the longest subsequence having Xor… Read More
Given a Binary Tree and an integer target, denoting the value of a node, the task is to find the sum of distances of all… Read More
Given a binary tree consisting of N nodes, the task is to find the sum of depths of all subtree nodes in a given binary… Read More
Given an array A[] of size N (1 ≤ N ≤ 105), the task is to calculate the number of swaps required to sort the… Read More
Given a 2D array edges[][] of type { X, Y } representing that there is an edge between the node X and Y in a… Read More
Given an array arr[] of size N and an integer K, the task is to print all possible ways to split the given array into… Read More
Given an array arr[] consisting of a single element N (1 ≤ N ≤ 106) and two integers L and R, ( 1 ≤ L… Read More
Given an integer N, the task is to count the number of ways to represent N as the sum of powers of 2. Examples: Input:… Read More
Given an array arr[] consisting of 2* N elements in the form of { a1, a2, …, aN, b1, b2, …, bN }, the task… Read More
Given a XOR linked list and an integer K, the task is to reverse every K nodes in the given XOR linked list. Examples: Input:… Read More
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… Read More
Given a list arr[] consisting of arrays of varying lengths, the task is to find the maximum product that can be formed by taking exactly… Read More