# Top 10 algorithms in Interview Questions | Set 2

In the previous post, top 10 algorithms/questions on different topics that are most asked in interviews is discussed.

In this post, top 10 problems on the rest of data-structures or algorithms are covered. If you are preparing for a coding interview, going through these problems is a must.

**Topics**:

**Stack & Queue****Tree / Binary Search Tree****Prefix Matching and Sliding Window****Heaps****Greedy Algorithms****Trie**

**Stack & Queue**

- Next greater element
- Balanced parenthesis
- Stock Span Problem
- Implement a stack using two queues
- Implement a queue using two stacks
- Implement 2 stacks in an array
- Implement k stacks in an array
- Implement a special stack that supports getMin() in O(1) time
- Implement LRU Cache
- Reverse a Stack

**Tree / Binary Search Tree**

- Check if a Binary Tree is BST
- Convert a given Binary Tree to Doubly Linked List
- Inorder Tree Traversal without recursion and without stack
- Level order traversal line by line
- Construct Tree from given Inorder and Preorder traversals
- Construct Full Binary Tree from given preorder and postorder traversals
- Find distance between two nodes of a Binary Tree
- Two nodes of a BST are swapped, correct the BST
- Print Left View of a Binary Tree
- Flatten a binary tree into linked list

**Prefix Matching and Sliding Window**

- Equilibrium Index
- Subarray with 0 sum
- Subarray with same number of 1s and 0s in a binary array
- Maximum sum of a subarray of size k
- Distinct elements in every window of size k
- Subarray with given sum in an array of positive numbers
- Minimum element in every window of size k
- N-bonacci Numbers
- Longest subsequence of the form 0*1*0* in a binary string
- Longest Span with same Sum in two Binary arrays

**Heaps**

- Median in a stream of integers (running integers)
- K’th largest element in a stream
- Sort a nearly sorted (or K sorted) array
- k largest(or smallest) elements in an array
- Merge k sorted arrays
- External Sorting
- Huffman Decoding
- Minimum sum of two numbers formed from digits of an array
- Find smallest range containing elements from k lists
- Check if a given Binary Tree is Heap

**Greedy Algorithms**

- Minimum Number of Platforms Required for a Railway/Bus Station
- Job Scheduling with two jobs allowed at a time
- Prim’s Minimum Spanning Tree (MST)
- Dijkstra’s shortest path algorithm
- Efficient Huffman Coding for Sorted Input
- Fractional Knapsack Problem
- Graph Coloring
- Greedy Algorithm to find Minimum number of Coins
- Minimize Cash Flow among a given set of friends who have borrowed money from each other
- Connect n ropes with minimum cost

**Trie**

- Find duplicate rows in a binary matrix
- Word Break Problem
- Longest Common Prefix in given set of strings
- Find the k most frequent words from a file
- Find shortest unique prefix for every word in a given list
- Longest prefix matching
- Find maximum XOR of given integer in a stream of integers
- Auto-complete feature using Trie
- Implement a Phone Directory
- Count of distinct substrings of a string using Suffix Trie

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: **DSA Self Paced**. Become industry ready at a student-friendly price.

## Recommended Posts:

- Top 10 algorithms in Interview Questions
- Top 20 Greedy Algorithms Interview Questions
- TCS Ninja Interview Experience and Interview Questions
- Top 25 Interview Questions
- SQL Interview Questions
- Facebook Interview Questions
- PHP Interview Questions and Answers
- Advanced SQL Interview Questions
- PHP Interview Questions and Answers | Set-2
- Amazon Interview Questions
- JavaScript Interview Questions and Answers | Set-2
- JavaScript Interview Questions and Answers | Set 3
- Commonly Asked C++ Interview Questions | Set 2
- Commonly Asked OOP Interview Questions | Set 1
- jQuery Interview Questions and Answers
- Top 20 Dynamic Programming Interview Questions
- Top 20 Backtracking Algorithm Interview Questions
- jQuery Interview Questions and Answers | Set-3
- Java Interview Questions on Constructors
- Deloitte Interview Questions and Tips

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.