Given a matrix grid[][] with dimension M × N of integers, the task is to print the matrix elements using DFS traversal. Examples: Input: mat[][]… Read More
Category Archives: Recursion
Given an array arr[] consisting of N integers, the task is to minimize the count of elements required to be multiplied by -1 such that… Read More
Given an integer N denoting the number of boxes in a pen, and two players P1 and P2 playing a game of distributing N pens… Read More
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 arr[] of size N and a 2D array Q[][] consisting of queries of the following two types: 1 X Y: Update 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 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