## Print Stack Elements from Bottom to Top

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

## Check whether two strings are equivalent or not according to given condition

Given two strings A and B of equal size. Two strings are equivalent either of the following conditions hold true: 1) They both are equal.… Read More »

## Count primes that can be expressed as sum of two consecutive primes and 1

Given a number N. The task is to count the number of prime numbers from 2 to N that can be expressed as a sum… Read More »

## Maximum positive integer divisible by C and is in the range [A, B]

Given three positive integers A, B and C. The task is to find the maximum integer X > 0 such that: X % C =… Read More »

## Sum of bitwise AND of all subarrays

Given an array consisting of N positive integers, find the sum of bit-wise and of all possible sub-arrays of the array. Examples: Input : arr[]… Read More »

## Sum of XOR of all subarrays

Given an array containing N positive integers, the task is to find the sum of XOR of all sub-arrays of the array. Examples: Input :… Read More »

## Find the longest Fibonacci-like subarray of the given array

Given an array of N elements, the task is to find the longest subarray which is Fibonacci-like. A Fibonacci-like sub-array is defined as an array… Read More »

## Find a permutation of 2N numbers such that the result of given expression is exactly 2K

Given two integers N and K, the task is to find a permutation of first 2*N natural numbers such that the following equation is satisfied.… Read More »

## Queries for number of distinct integers in Suffix

Given an array of N elements and Q queries, where each query contains an integer K. For each query, the task is to find the… Read More »

## DP on Trees | Set-3 ( Diameter of N-ary Tree )

Given an N-ary tree T of N nodes, the task is to calculate the longest path between any two nodes(also known as the diameter of… Read More »

## Minimum index i such that all the elements from index i to given index are equal

Given an array arr[] of integers and an integer pos, the task is to find the minimum index i such that all the elements from… Read More »

## Find a positive number M such that gcd(N^M, N&M) is maximum

Given a number N, the task is to find a positive number M such that gcd(N^M, N&M) is the maximum possible and M < N.… Read More »

## Delete nodes which have a greater value on right side using recursion

Given a singly linked list, remove all the nodes which have a greater value on the right side. Examples: a) The list 12->15->10->11->5->6->2->3->NULL should be… Read More »

## Source to destination in 2-D path with fixed sized jumps

Given the source point and the destination point of the path and two integers x and y. The task is to check whether it is… Read More »

## Minimize the sum of the squares of the sum of elements of each group the array is divided into

Given an array consisting of even number of elements, the task is to divide the array into M group of elements (every group must contain… Read More »