Given a linked list containing 0’s, 1’s and 2’s, sort linked list by doing single traversal of it.
Find maximum amount of water that can be trapped within given set of bars. Assume width of each bar is 1 unit.
Given two sorted array of integers, find a 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.
Given an array of integers, find contiguous subarray within it which has the largest sum.
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.
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.
Given an array containing only 0’s, 1’s and 2’s, sort the array in linear time and using constant space.
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 …
A Binary Search Tree (BST) is a rooted binary tree, whose nodes each store a key (and optionally, an associated value) and each have two distinguished sub-trees, commonly denoted left and right. The tree should satisfy the BST property, which states that the key in each node must be greater than all keys stored …
Given a binary tree, in-place convert it to a Doubly Linked List.
Given a binary tree, write an efficient algorithm to print all paths from root node to every leaf node in it.
Given a binary tree and two nodes x and y in it, find lowest common ancestor (LCA) of x and y in it.