Number of integers in a range [L, R] which are divisible by exactly K of it’s digits
Given a range of values [L, R] and a value K, the task is to count the numbers in the given range which are divisible by at least K of the digits present in the decimal representation of that number....
read more
All possible binary numbers of length n with equal sum in both halves
Given a number n, we need to print all n-digit binary numbers with equal sum in left and right halves. If n is odd, then mid element can be either 0 or 1....
read more
Find a number such that maximum in array is minimum possible after XOR
Given an array of non-negative integers. Choose an integer P and take XOR of P with all elements of the array. The task is to choose P such that the maximum value of the array is minimum possible after performing XOR of all elements of the array with P....
read more
Print all the root-to-leaf paths of a Binary Tree whose XOR is non-zero
Given a Binary Tree, the task is to print all root-to-leaf paths of this tree whose xor value is non-zero....
read more
Count all possible visited cells of a knight after N moves
Given the current position of a Knight as (i, j), find the count of different possible positions visited by a knight after N moves (in a 10 x 10 board)....
read more
Minimum length of Run Length Encoding possible by removing at most K characters from a given string
Given a string S of length N, consisting of lowercase English alphabets only, the task is to find the minimum possible length of run-length-encoding that can be generated by removing at most K characters from the string S....
read more
Kth character from the Nth string obtained by the given operations
Given two positive integers N and K, the task is to find the Kth character of a string obtained by performing the following operation on a string S( initially “A”) N times....
read more
Number of ways such that only K bars are visible from the left
Given a number K, and N bars of height from 1 to N, the task is to find the number of ways to arrange the N bars such that only K bars are visible from the left....
read more
Kth ancestor of all nodes in an N-ary tree using DFS
Given an N-ary tree and an integer K, the task is to print the Kth ancestors of all the nodes of the tree in level order manner. If K ancestors does not exist for a node, then print -1 for that node....
read more
Recursively remove all adjacent duplicates
Given a string, recursively remove adjacent duplicate characters from the string. The output string should not have any adjacent duplicates. See the following examples....
read more
Maximum product of a pair of nodes from largest connected component in a Graph
Given an undirected weighted graph G consisting of N vertices and M edges, and two arrays Edges[][2] and Weight[] consisting of M edges of the graph and weights of each edge respectively, the task is to find the maximum product of any two vertices of the largest connected component of the graph, formed by connecting all edges with the same weight....
read more
Sum of N-terms of geometric progression for larger values of N | Set 2 (Using recursion)
A Geometric series is a series with a constant ratio between successive terms. The first term of the series is denoted by a and the common ratio is denoted by r. The series looks like this:- The task is to find the sum of such a series, mod M....
read more