Given a Stack S, the task is to print the elements of the stack from top to bottom such that the elements are still present… Read More

# Category Archives: Recursion

Given an array arr[] consisting of N integers, the task is to find all the array elements which occurs more than floor (n/3) times. Examples:… Read More

Given a positive integer N, the task is to print the last remaining element from a sequence [1, N] after repeatedly performing the following operations… Read More

Given an array arr[] of size N, the task is to find the minimum moves to the beginning or end of the array required to… Read More

Given an n-ary tree T, the task is to find a node whose removal minimizes the maximum size of all forests(connected components) generated. Examples: Input: … Read More

Given a binary tree, the task is to count the number of balanced nodes in the given tree. Balanced nodes of a binary tree are… Read More

Given a binary tree, the task is to traverse each level of the given binary tree from left to right and print every alternate encountered… Read More

Given a Binary Search Tree, the task is to print the nodes of the BST in the following order: If the BST contains levels numbered… Read More

Given two arrays arr[] and brr[] of size N such that the array brr[] consists of scores associated with corresponding elements of the array arr[].… Read More

Given an array arr[] consisting of N integers, the task is to find the maximum subsequence sum by multiplying each element of the resultant subsequence… Read More

Given three integers L, R and K where [L, R] denotes the range of elements, the task is to find the element in the range… Read More

Given an array, arr[] of size N consisting of elements from the range [1, N], that represents the order, in which the elements are inserted… Read More

Given an undirected graph with N vertices and K edges, the task is to check if for every combination of three vertices in the graph,… Read More

Given an array arr[] of size N representing the available denominations and an integer X. The task is to find any combination of the minimum… Read More

Given a string, str, the task is to remove all the duplicate adjacent characters from the given string. Examples: Input: str= “azxxzy”Output: ay Removal of “xx”… Read More