## Find count of distinct elements in every sub-array of size k

Given an array and an integer k, find the count of distinct elements in every sub-array of size k in the array.

## Find all employees who directly or indirectly reports to a manager

Given a map containing employee to manager mappings, find all employees under each manager who directly or indirectly reports to him.

## Build Binary Tree from given Parent array

Given an array A which represents a binary tree such that the parent-child relationship is defined by (A[i], i) for every index i in the array A, build binary tree out of it. The value of root node will be i if -1 is present at index i in the array. It may be assumed …

## Sort linked list containing 0’s, 1’s and 2’s in single traversal

Given a linked list containing 0’s, 1’s and 2’s, sort linked list by doing single traversal of it.

## Convert number to words in C++ and Java

Write an efficient program to convert number to words in C++ and Java programming langauge.

## Trapping Rain Water within given set of bars

In trapping rain water problem, we need to find the maximum amount of water that can be trapped within given set of bars where width of each bar is 1 unit.

## Find maximum sum path involving elements of given arrays

Given two sorted array of integers, find a maximum sum path involving elements of both arrays whose sum is maximum. We can start from either arrays but we can switch between arrays only through its common elements.

## Maximum Subarray Problem (Kadane’s algorithm)

Given an array of integers, find contiguous subarray within it which has the largest sum.

## Find a duplicate element in a limited range array

Given a limited range array of size n where array contains elements between 1 to n-1 with one element repeating, find the duplicate number in it.

## Find majority element in an array (Boyer–Moore majority vote algorithm)

Given an array of integers containing duplicates, return the majority element in an array if present. A majority element appears more than n/2 times where n is the size of the array.

## Sort an array containing 0’s, 1’s and 2’s (Dutch national flag problem)

Given an array containing only 0’s, 1’s and 2’s, sort the array in linear time and using constant space.

## Determine if given Binary Tree is a BST or not

Given a Binary Tree, determine if it is a BST or not.   This problem has a simple recursive solution. The BST property “every node on the right subtree has to be larger than the current node and every node on the left subtree has to be smaller than the current node” is the key …