Index

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

Array


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
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)
BitsCalculate power
Next power of two
Total 1s in numbers till n
Swap without temp

Queue

Snakes and ladders
Queue using stack
Queue minimum using stack
Shortest path in a maze

Map

Linked list with random pointer
Same average subset
Anagram substring search

Heap

Running Median
Maximum k integers using min heap
Max heap and BST in one
Merge N sorted arrays

Backtracking

Separate words in sentence
Increasing decreasing tuple

Multithreading

Distributed doubly linked list sum
Distributed node sum of tree
Distributed circular linked list sum

Graph

Find order of letters
Find longest interviewer chain

Divide and conquer

Find local minima

Stack

Array next element
Stack with get minimum
Sort a stack
Find all permutations
Find all paths in a maze
Find longest path in maze
Towers of Hanoi

Hash

All unique letter substring
Linked list remove duplicate
Are two words anagram
Longest subarray equal 1 & 0
Pythagorean triples

Tree

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

Dynamic programming

Two numbers sum up to k
Two numbers sum up to k unsorted
Any numbers sum up to k iterative
Any numbers sum up to k recursive
Container loading recursive
Largest palindrome dynamic
Longest common subsequence
Gold coins in pots game
Partition array equal sum
Find subset with given average
Increasing array subsequence