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

  1. Next greater element
  2. Balanced parenthesis
  3. Stock Span Problem
  4. Implement a stack using two queues
  5. Implement a queue using two stacks
  6. Implement 2 stacks in an array
  7. Implement k stacks in an array
  8. Implement a special stack that supports getMin() in O(1) time
  9. Implement LRU Cache
  10. Reverse a Stack

Tree / Binary Search Tree

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

Prefix Matching and Sliding Window

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

Heaps

  1. Median in a stream of integers (running integers)
  2. K’th largest element in a stream
  3. Sort a nearly sorted (or K sorted) array
  4. k largest(or smallest) elements in an array
  5. Merge k sorted arrays
  6. External Sorting
  7. Huffman Decoding
  8. Minimum sum of two numbers formed from digits of an array
  9. Find smallest range containing elements from k lists
  10. Check if a given Binary Tree is Heap

Greedy Algorithms

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

Trie

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


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.