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

Find maximum and minimumMake 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 iterativeReverse 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

## Stack

Array next elementStack with get minimum

Sort a stack

Find all permutations

Find all paths in a maze

Find longest path in maze

Towers of Hanoi

## Queue

Snakes and laddersQueue using stack

Queue minimum using stack

Shortest path in a maze

## Hash

All unique letter substringLinked list remove duplicate

Are two words anagram

Longest subarray equal 1 & 0

Pythagorean triples

## Map

Linked list with random pointerSame average subset

Anagram substring search

## Heap

Running MedianMaximum k integers using min heap

Max heap and BST in one

Merge N sorted arrays

## Backtracking

Separate words in sentenceIncreasing decreasing tuple

## Tree

Balance the balanceLowest 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

## Multithreading

Distributed doubly linked list sumDistributed node sum of tree

Distributed circular linked list sum

## Graph

Find order of lettersFind longest interviewer chain

## Divide and conquer

Find local minima## Dynamic programming

Two numbers sum up to kTwo 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

Share price max profit recursive

Increasing array subsequence