# Category Archives: Recursion

Given three positive integers M, X, and Y, the task is to find the minimum number of operations required to make X and Y equal… Read More
Given an array arr[] consisting of N positive integers and a positive integer K, the task is to maximize the GCD of the array arr[]… Read More
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… Read More
Given an N-ary Tree consisting of N nodes valued from [1, N], where node 1 is the root, the task is to count the pairs… Read More
Given an integer N, the task is to count the number of prime factors of N!. Examples: Input: N = 5Output: 3Explanation: Factorial of 5… Read More
Given an array arr[] consisting of N positive integers, the task is to find the minimum cost required to either cross the array or reach… Read More
Given a positive integer N, the task is to find the number of binary strings of length N which contains “11” as a substring. Examples:… Read More
Given a binary tree consisting of N nodes, the task is to check if the nodes in the top view of a Binary Tree forms… Read More
Given a positive integer N, the task is to construct the lexicographically largest array of size (2 * N – 1) comprising of first N… Read More
Given an array nums[] of size N, the task is to print all possible distinct permutations of the array nums[] (including duplicates). Input: nums[] =… Read More
Given an integer N and a 2D array cost[][3], where cost[i][0], cost[i][1], and cost[i][2] is the cost of painting ith house with colors red, blue,… Read More
Given a positive number N, the task is to find the sum of the first (N + 1) Fibonacci Numbers. Examples: Input: N = 3Output:… Read More
Given an array input[] consisting only of 1s initially and an array target[] of size N, the task is to check if the array input[]… Read More
Given an undirected graph G with vertices numbered in the range [1, N] and an array Edges[][] consisting of M edges, the task is to… Read More
Given an integer N, denoting the number of computers connected by cables forming a network and a 2D array connections[][], with each row (i, j)… Read More