Must-Do-Coding-Questions-for-Companies
Must-Do-Coding-Questions-for-Companies copied to clipboard
Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, etc. It also help to crack the technical inteviews.
Must Do Coding Questions in Java
Array
| S.No | Question Link | Solution | Difficulty |
|---|---|---|---|
| 1 | Subarray with given sum | Subarray with given sum | Easy |
| 2 | Kadane's Algorithm | Kadane's Algorithm | Medium |
| 3 | Missing number in array | Missing number in array | Easy |
| 4 | Merge Without Extra Space | Merge Without Extra Space | Hard |
| 5 | Rearrange Array Alternately | Rearrange Array Alternately | Medium |
| 6 | Largest Number formed from an Array | Largest Number formed from an Array | Medium |
| 7 | Spirally traversing a matrix | Spirally traversing a matrix | Easy |
| 8 | Convert array into Zig-Zag fashion | Convert array into Zig-Zag fashion | Easy |
| 9 | Trapping Rain Water | Trapping Rain Water | Medium |
| 10 | Kth smallest element | Kth smallest element | Medium |
| 11 | Reverse array in groups | Reverse array in groups | Basic |
| 12 | Minimum Platforms | Minimum Platforms | Medium |
| 13 | Leaders in an array | Leaders in an array | Easy |
| 14 | Equilibrium Point | Equilibrium Point | Easy |
| 15 | Reverse Array | Reverse array | Easy |
| 16 | Sort 0 1 2 | Sort 0 1 2 | Easy |
| 17 | Remove Duplicates from Sorted Array | Remove Duplicates from Sorted Array | Easy |
| 18 | Rotate Array | Rotate Array | Easy |
| 19 | Maximum of all subarrays of size k | Maximum of all subarrays of size k | Medium |
| 20 | Single Number | Single Number | Easy |
| 21 | Intersection of Two Arrays II | Intersection of Two Arrays II | Easy |
| 22 | Count Triplets | Count Triplets | Medium |
| 23 | Help Classmates | Help Classmates | Medium |
| 24 | Maximum Product Subarray | Maximum Product Subarray | Medium |
| 25 | Reshape the Matrix | Reshape the Matrix | Easy |
| 26 | Valid Sudoku | Valid Sudoku | Easy |
| 27 | Subarrays with equal 1s and 0s | Subarrays with equal 1s and 0s | Medium |
| 28 | First non-repeating character in a stream | First non-repeating character in a stream | Easy |
| 29 | First negative integer in every window of size k | First negative integer in every window of size k | Easy |
| 29 | Valid Substring | Valid Substring | Easy |
| 30 | The Celebrity Problem | The Celebrity Problem | Medium |
| 31 | Median of Two Sorted Arrays | Median of Two Sorted Arrays | Medium |
| 32 | Maximum Rectangular Area in a Histogram | Maximum Rectangular Area in a Histogram | Medium |
| 33 | Count pairs in array divisible by K | Count pairs in array divisible by K | Medium |
Searching Algo
| S.No | Question Link | Solution | Difficulty |
|---|---|---|---|
| 1 | Linear Search | Linear Search | Basic |
| 2 | Binary Search | Binary Search | Basic |
| 3 | First Bad Version | First Bad Version | Easy |
| 4 | Search Insert Position | Search Insert Position | Easy |
| 5 | Search in Rotated Sorted Array | Search in Rotated Sorted Array | Medium |
| 6 | Find Missing And Repeating | Find Missing And Repeating | Medium |
| 7 | Majority Element | Majority Element | Medium |
| 8 | Searching in an array where adjacent differ by at most k | Searching in an array where adjacent differ by at most k | Medium |
| 9 | Find Pair Given Difference | Find Pair Given Difference | Easy |
| 10 | Zero Sum Subarrays | Zero Sum Subarrays | Medium |
Sorting Algo
| S.No | Question Link | Solution | Difficulty |
|---|---|---|---|
| 1 | Bubble Sort | Bubble Sort | Basic |
| 2 | Selection Sort | Selection Sort | Basic |
| 3 | Insertion Sort | Insertion Sort | Easy |
| 4 | Merge Sort | Merge Sort | Easy |
Martix
| S.No | Question Link | Solution | Difficulty |
|---|---|---|---|
| 1 | Spirally traversing a matrix | Spirally traversing a matrix | Medium |
| 2 | Search a 2D Matrix | Search a 2D Matrix | Medium |
| 3 | Row with max 1s | Row with max 1s | Medium |
| 4 | Sorted matrix | Sorted matrix | Basic |
| 5 | Maximal Square | Maximal Square | Medium |
| 6 | Rotate Image | Rotate Image | Medium |
| 7 | Common Elements Present In All Rows Of Matrix | Common Elements Present In All Rows Of Matrix | Medium |
| 8 | Solve the Sudoku | Solve the Sudoku | Medium |
String
| S.No | Question Link | Solution | Difficulty |
|---|---|---|---|
| 1 | Longest Common Prefix in an Array | Longest Common Prefix in an Array | Medium |
| 2 | Reverse words in a given string | Reverse words in a given string | Easy |
| 3 | Permutations of a given string | Permutations of a given string | Basic |
| 4 | Longest Palindrome in a String | Longest Palindrome in a String | Medium |
| 5 | Roman Number to Integer | Roman Number to Integer | Easy |
| 6 | Convert to Roman No | Convert to Roman No r | Easy |
| 7 | Anagram | Anagram | Easy |
| 8 | Longest Substring Without Repeating Characters | Longest Substring Without Repeating Characters | Medium |
| 9 | First Unique Character in a String | First Unique Character in a String | Medium |
| 10 | Search Pattern | Search Pattern | Medium |
LinkedList
| S.No | Question Link | Solution | Difficulty |
|---|---|---|---|
| 1 | Finding middle element in a linked list | Finding middle element in a linked list | Basic |
| 2 | Reverse a linked list | Reverse a linked list | Easy |
| 3 | Rotate a Linked List | Rotate a Linked List | Easy |
| 4 | Reverse a Linked List in groups of given size | Reverse a Linked List in groups of given size | Medium |
| 5 | Intersection Point in Y Shapped Linked Lists | Intersection Point in Y Shapped Linked Lists | Medium |
| 6 | Detect Loop in linked list | Detect Loop in linked list | Easy |
| 7 | Nth node from end of linked list | Nth node from end of linked list | Easy |
| 8 | Merge two sorted linked lists | Merge two sorted linked lists | Easy |
| 9 | Add two numbers represented by linked lists | Add two numbers represented by linked lists | Easy |
| 10 | Check if Linked List is Palindrome | Check if Linked List is Palindrome | Easy |
| 11 | Flattening a Linked List | Flattening a Linked List | Medium |
| 12 | Given a linked list of 0s, 1s and 2s, sort it | Given a linked list of 0s, 1s and 2s, sort it | Easy |
| 13 | Remove duplicate | Remove duplicate | Easy |
| 14 | Find length of Loop | Find length of Loop | Easy |
| 15 | Remove duplicates from an unsorted linked list | Remove duplicates from an unsorted linked list | Easy |
| 16 | Reverse a Doubly Linked List | Reverse a Doubly Linked List | Easy |
| 17 | Segregate even and odd nodes in a Link List | Segregate even and odd nodes in a Link List | Easy |
| 18 | Delete nodes having greater value on right | Delete nodes having greater value on right | Medium |
| 20 | Add 1 to a number represented as linked list | Add 1 to a number represented as linked list | Easy |
| 21 | Merge Sort for Linked List | Merge Sort for Linked List | Easy |
| 22 | Quick Sort on Linked List | Quick Sort on Linked List | Medium |
| 23 | Middle of the Linked List | Middle of the Linked List | Medium |
| 24 | Split a Circular Linked List into two halves | Split a Circular Linked List into two halves | Medium |
| 25 | Clone a linked list with next and random pointer | Clone a linked list with next and random pointer | Medium |
| 26 | Reverse Nodes in k-Group | Reverse Nodes in k-Group | Medium |
| 27 | Reverse Linked List II | Reverse Linked List II | Medium |
| 28 | Flatten Binary Tree to Linked List | Flatten Binary Tree to Linked List | Medium |
| 29 | Swapping Nodes in a Linked List | Swapping Nodes in a Linked List | Medium |
| 30 | Merge In Between Linked Lists | Merge In Between Linked Lists | Medium |
| 31 | Delete node in Doubly Linked List | Delete node in Doubly Linked List | Basic |
Tree
| S.No | Question Link | Solution | Difficulty |
|---|---|---|---|
| 1 | Left View of Binary Tree | Left View of Binary Tree | Easy |
| 2 | Count Leaves in Binary Tree | Count Leaves in Binary Tree | Basic |
| 3 | Diameter of Binary Tree | Diameter of Binary Tree | Easy |
| 4 | Height of Binary Tree | Height of Binary Tree | Basic |
| 5 | Check for Balanced Tree | Check for Balanced Tree | Easy |
| 6 | Symmetric Tree | Symmetric Tree | Easy |
| 7 | Identical Tree | Identical Tree | Easy |
| 8 | Connect Nodes at Same Level | Connect Nodes at Same Level | Medium |
| 9 | Level order traversal in spiral form | Level order traversal in spiral form | Easy |
| 10 | Level order traversal | Level order traversal | Easy |
| 11 | Inorder Traversal | Inorder Traversal | Easy |
| 12 | Preorder Traversal | Preorder Traversal | Easy |
| 13 | Postorder Traversal | Postorder Traversal | Easy |
| 14 | Delete without head pointer | Delete without head pointer | Medium |
| 15 | Reverse Level Order Traversal | Reverse Level Order Traversal | Easy |
| 16 | Invert Binary Tree | Invert Binary Tree | Easy |
| 17 | Right View of Binary Tree | Right View of Binary Tree | Easy |
| 18 | Top View of Binary Tree | Top View of Binary Tree | Medium |
| 19 | Bottom View of Binary Tree | Bottom View of Binary Tree | Medium |
| 20 | Minimum Depth of Binary Tree | Minimum Depth of Binary Tree | Easy |
| 21 | ZigZag Tree Traversal | ZigZag Tree Traversal | Easy |
| 22 | Diagonal Traversal of Binary Tree | Diagonal Traversal of Binary Tree | Medium |
| 23 | Check if Tree is Isomorphic | Check if Tree is Isomorphic | Medium |
| 24 | Lowest Common Ancestor in a Binary Tree | Lowest Common Ancestor in a Binary Tree | Medium |
| 25 | Binary Tree to DLL | Binary Tree to DLL | Hard |
| 26 | Boundary Traversal of binary tree | Boundary Traversal of binary tree | Medium |
| 27 | Construct Tree from Inorder & Preorder | Construct Tree from Inorder & Preorder | Medium |
| 28 | Sum Tree | Sum Tree | Medium |
| 29 | Duplicate subtree in Binary Tree | Duplicate subtree in Binary Tree | Medium |
| 30 | Duplicate Subtrees | Duplicate Subtrees | Medium |
| 31 | Maximum sum of Non-adjacent nodes | Maximum sum of Non-adjacent nodes | Medium |
| 32 | Sum of nodes on the longest path from root to leaf node | Sum of nodes on the longest path from root to leaf node | Easy |
| 33 | Clone a Binary Tree | Clone a Binary Tree | Medium |
| 34 | K distance from root | K distance from root | Easy |
| 35 | Diagonal Sum In Binary Tree | Diagonal Sum In Binary Tree | Easy |
| 36 | Perfect Binary Tree | Perfect Binary Tree | Easy |
| 37 | Leaves to DLL | Leaves to DLL | Medium |
Binary Search Tree
| S.No | Question Link | Solution | Difficulty |
|---|---|---|---|
| 1 | Check for BST | Check for BST | Medium |
| 2 | Lowest Common Ancestor in a BST | Lowest Common Ancestor in a BST | Medium |
| 3 | Largest BST | Largest BST | Medium |
| 4 | Insert a node in a BST | Insert a node in a BST | Basic |
| 5 | Minimum element in BST | Minimum element in BST | Basic |
| 6 | Count BST nodes that lie in a given range | Count BST nodes that lie in a given range | Medium |
| 7 | Flatten BST To A Sorted List | Flatten BST To A Sorted List | Medium |
| 8 | Preorder to Postorder | Preorder to Postorder | Medium |
| 9 | Normal BST to Balanced BST | Normal BST to Balanced BST | Easy |
Stack and Queue
| S.No | Question Link | Solution | Difficulty |
|---|---|---|---|
| 1 | Reverse Stack Using Recursion | Reverse Stack Using Recursion | Easy |
| 2 | Sort a stack | Sort a stack | Easy |
| 3 | Merge Intervals | Merge Intervals | Medium |
| 4 | Valid Substring | Valid Substring | Easy |
| 5 | LRU Cache | LRU Cache | Easy |
| 6 | Queue Reversal | Queue Reversal | Easy |
| 7 | Implement two stacks in an array | Implement two stacks in an array | Easy |
| 8 | Next Smaller Element | Next Smaller Element | Medium |
| 9 | First non-repeating character in a stream | First non-repeating character in a stream | Medium |
| 10 | Game with String | Game with String | Medium |
| 11 | First negative integer in every window of size k | First negative integer in every window of size k | Medium |
| 12 | Reverse First K elements of Queue | Reverse First K elements of Queue | Easy |
| 13 | Maximum of all subarrays of size k | Maximum of all subarrays of size k | Medium |
| 14 | Rotten Oranges | Rotten Oranges | Medium |
| 15 | Special Stack | Special Stack | Medium |
| 16 | Queue using two Stacks | Queue using two Stacks | Easy |
| 17 | Flood fill Algorithm | Flood fill Algorithm | Medium |
| 18 | Distance of nearest cell having 1 | Distance of nearest cell having 1 | Medium |
| 19 | Circular tour | Circular tour | Medium |
Dynamic Programming
| S.No | Question Link | Solution | Difficulty |
|---|---|---|---|
| 1 | Min Cost Climbing Stairs | Min Cost Climbing Stairs | Easy |
| 2 | Coin Change | Coin Change | Medium |
| 3 | 0 - 1 Knapsack Problem | 0 - 1 Knapsack Problem | Medium |
| 4 | nCr | nCr | Medium |
| 5 | House Robber | House Robber | Medium |
| 6 | House Robber II | House Robber II | Medium |
| 7 | Jump Game | Jump Game | Medium |
| 8 | Longest Increasing Subsequence | Longest Increasing Subsequence | Medium |
| 9 | Longest Common Subsequence | Longest Common Subsequence | Medium |
| 10 | Maximum path sum in matrix | Maximum path sum in matrix | Medium |
| 11 | Edit Distance | Edit Distance | Medium |
| 12 | House Robber III | House Robber III | Medium |
| 13 | Minimum sum partition | Minimum sum partition | Hard |
| 14 | Subset Sum Problem | Subset Sum Problem | Medium |
| 15 | Partition Equal Subset Sum | Partition Equal Subset Sum | Medium |
| 16 | Knapsack with Duplicate Items | Knapsack with Duplicate Items | Medium |
| 17 | Rod Cutting | Rod Cutting | Medium |
| 18 | Coin Change 2 | Coin Change 2 | Medium |
| 19 | Longest Common Substring | Longest Common Substring | Medium |
| 20 | Longest Palindromic Subsequence | Longest Palindromic Subsequence | Medium |
| 21 | Minimum number of deletions and insertions | Minimum number of deletions and insertions | Easy |
| 22 | Shortest Common Supersequence | Shortest Common Supersequence | Medium |
| 23 | Minimum number of deletions | Minimum number of deletions | Easy |
| 24 | Longest Repeating Subsequence | Longest Repeating Subsequence | Easy |
Mathematics
| S.No | Question Link | Solution | Difficulty |
|---|---|---|---|
| 1 | Find Nth root of M | Find Nth root of M | Easy |
| 2 | Kth Smallest Factor | Kth Smallest Factor | Easy |
| 3 | Square root of a number | Square root of a number | Medium |