Data structures and algorithm book

We are presenting a collection of data structure and algorithm questions and answers for technical interviews for software companies. Questions are collected from real interviews of companies like Microsoft, Amazon, Facebook, Google or Yahoo. Questions are solved and the solutions are discussed in an optimal way which enables you to do a quick preparation for interview. A complete running Java program is added with each problem which you can copy and run in your IDE to understand the solution in a better way. Your feedback is very much appreciated. Please help the site grow by sharing your own problem and solutions or suggestions. Please contact us through feedback@dsalgo.com

Categorized content


Make larger number
Next larger palindrome
Least difference in array
Print matrix spiral
Move zeros to the right
Find repetition multiple sorted arrays
Largest sum sub array
Search in a sorted matrix
Kth largest in sorted matrix
Largest palindrome iterative
Reverse words of sentence
Rotate array k times
Merge in single array
Rotate a string to make another
Maximum product subarray
Maximum sum sub matrix
Expand the array
Sort to bring anagrams closer
Two missing numbers
Maximize stock profit simple
Sum of array except current element
Maximum arithmetic sequence

Linked list

Reverse linked list iterative
Reverse linked list recursive
Fold a linked list
Reverse k nodes in linked list
Find loop in linked list
Linked list Y shape
Kth node from end
Get find delete in O(1)


Calculate power
Next power of two
Total 1s in numbers till n
Swap without temp


Balance the balance
Lowest common ancestor
Sum of child nodes
Lowest common ancestor without root
Binary tree zigzag print
Print Binary tree bottom to top
Binary tree bottom to top level wise
Print Nodes of the same level
Linked list with inorder successor
Linked list with preorder successor
Linked list with postorder successor
Binary tree to linked list
Is the binary tree BST
Create tree from in and pre
Find root to node path
Find distance between two nodes
SuperImpose Binary Tree
Is a sum possible along any path
Remove duplicate infinite integer
Find deepest level nodes
Maximum sum path positive
Maximum sum path negative
Find Kth smallest in BST
BST with insertion order
Binary tree sum of odd levels
Level order without queue
Print level with maximum nodes
Find all wrong pairs in a BST
Depth of tree from parent array
BST from doubly linked list