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
Please Login to comment...