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:

Serialize and Deserialize Binary Tree using one traversal


Populate inorder successor for all nodes.

Check if given binary tree is a BST