Exercises

Stack   Linked List    Array and String   Binary Tree



Stack/Queue:

Design a Data Structure which supports push, pop and findMin operation in O(1).

Design a stack with additional operations on middle element.

Implement stack using two queues


Linked List:

Reverse a Linked List in groups of given size.

Delete a node from singly linked list when only pointer to node to be deleted is given in O(1).

Given pointers to two Single Linked List find out if they joined in Y shape and also at which node they are joined.

Merge sort

Reverse a Linked List using one pointer.

Pairwise swap nodes of a given linked list.

Rotate a Linked List.


Array and String:

Remove duplicate characters from a string in O(n).

Nearest smaller numbers on left side

Merge overlapping Interval

Maximum Product Subarray

Sort array which contains only 0, 1 or 2 in O(n).

Print all permutations of a string

Array partition problem

Equilibrium point of an array

Longest Palindromic Subsequence

Longest Common Substring

You are given an array of n+2 elements. All elements in the array are in range 1 to n and all elements occur once except two numbers which occur twice. Find the two repeating numbers.

Find the maximum sum of sub array within an array.

Search an element in sorted rotated array

Number of inversions in an array

Find second-largest number in the array

Find nth minimum element in an array

Sort an array in wave form

Median of two sorted array


Binary Tree:

Check for children sum property in a binary tree.

Width of binary tree

Size of binary tree

Kth max in BSTree

Kth min in BSTree

Boundary traversal

Vertical order traversal

Level order traversal

Top view of binary tree

Left view of binary tree

Right view of binary tree

Bottom view of binary tree

Least Common Ancestor of two nodes in a Binary Tree.

Find depth of a binary tree.

Print all leaves

Inorder traversal of a binary tree without recursion

Preorder traversal of a binary tree without recursion

Postorder traversal of a binary tree without recursion

Populate inorder successor for all nodes.

Check if given binary tree is a BST