- DSA Tutorial
- Data Structures
- Linked List
- Dynamic Programming
- Binary Tree
- Binary Search Tree
- Divide & Conquer
- Mathematical
- Backtracking
- Branch and Bound
- Pattern Searching
Practice For Cracking Any Coding Interview
The coding questions in this article are difficulty-wise ordered . The idea of this post is to target two types of people.
- Competitive Programming Preparation (For I st and II nd Year Students): It is recommended to finish all questions from all categories except possibly Linked List, Tree, and BST. However, at least 10 questions from these categories should also be covered. If you have never done competitive programming before, it is strongly recommended to see How to Begin with Competitive Programming first.
- Interview preparation: It is recommended to cover all topics. In every topic, you can start with questions according to your comfort level.
The practice system tells you exactly the test case where your code failed. In case you need more clarity about a question, you may use the expected output button to see the output for your given input. You can also view others’ successful submissions in case you are stuck. To see the solutions of others , please click the “All Submissions” button at the bottom of the problem statement.
Cracking coding interviews demands persistent practice, and the GeeksforGeeks Practice Platform provides a structured approach to solving problems that mirror real interview questions.
Top Coding Interview Questions
Here are the top coding interview questions that you must practice to increase your chances of success in interviews. These questions are categorized by different topics for better preparation.
Ace your technical interviews with our Complete Interview Preparation course! Get comprehensive coverage of all key topics like arrays, dynamic programming, trees, and more, designed to help you succeed in coding interviews. Perfect for beginners and pros alike!
Mathematical Problems
- Print the pattern (You only need to write the function here)
- Print table (This is a full code problem. Please see sample codes here before attempting the problem)
- Closest Number
- Armstrong Numbers
- Sum of digits of a number
- Reverse digits
- Print the Kth Digit
- Binary number to decimal number
- Jumping Numbers
- GCD of two numbers
- LCM of two numbers
- Add two fractions
- GCD of array
- Factorial of a number
- Compute nPr
- Compute nCr
- Largest prime factor
- Perfect Numbers
- Pair cube count
- Find Nth root of M
- Prime Number
- Sieve of Eratosthenes
- Sum of all prime numbers between 1 and N .
- Pairs of prime numbers
Related Learning Resources:
Mathematical Algorithms Number Theory
Puzzles Problems
- Count Squares
- Check if four points form a square
- Check for power
- Overlapping rectangles
- Trailing zeroes in factorial
- Angle between hour and minute hand
- Number Of Open Doors
- Triangular Numbers
- Nth Even Fibonacci Number
- Last two digit Fibonacci
- Squares in a Matrix
- Day of the week
Related Learning Resources: Puzzles
Arrays Problems
- Array operations (Search, insert, delete)
- Array alternate printing
- Maximum and minimum in an array
- Second largest in array
- Sum of array elements
- Reverse an Array
- Rotate Array
- Count of smaller elements
- Remove duplicate elements from sorted Array
- Count possible triangles
- Leaders in an array
- Minimum distance between two numbers
- Sorted subsequence of size 3
- Maximum Sub Array
- Majority Element
- Maximum Index
- Max sum path in two arrays
- Product array puzzle
- Find duplicates in a small ranged array
- Find Missing And Repeating
- Stock buy and sell
- Trapping Rain Water
- Pair with given sum in a sorted array
- Chocolate Distribution Problem
- Longest Consecutive subsequence
- Three way partitioning
Related Learning Resources: Array Data Structure
String Problems
- Check for palindrome
- Check for anagram
- Anagram Palindrome
- Title case conversion
- Sort the string
- Merge two strings
- Save Ironman
- Good or Bad string
- URLify a given string
- Extract Maximum
- Reverse words in a given string
- Implement strstr
- Check for subsequence
- Check for rotation
- Check if two strings are k-anagrams
- Uncommon characters
- Anagram Search
- First repeating character
- First non-repeating character
- Longest Distinct characters in string
- Longest Palindromic Substring
- Find k-th character in string
- Smallest window in a string containing all characters of another string
- Add Binary Strings
- Multiply two Strings
- Nearest multiple of 10
Related Learning Resources: String Data Structure
Searching Problems
- Linear Search
- Facing the sun
- Magnet Array Problem
- Binary Search
- Floor in a Sorted Array
- Count occurrences in a sorted array
- Search in a sorted and rotated
- Find the missing number
- Missing element of AP
- Square root of a number
- Find Transition Point in a Sorted Binary Array
- Last index of One
- Peak element
- Allocate minimum number of pages
- Common elements in three sorted
- Smallest Positive missing number
Related Learning Resources : Searching Algorithms
Sorting Problems
- Check if array is sorted
- Sort a binary array
- Sort an array of 0s, 1s and 2s
- Bubble Sort
- Insertion Sort
- Selection Sort
- Sort an array when two halves are sorted
- Relative Sorting
- Triplet Sum in Array
- Minimum Swaps to Sort
- Sorting elements by frequency
- Triplet Family
- Count the triplets
Related Learning Resources: Sorting Algorithms
Hashing Problems
- Count distinct elements
- Array Subset of another array
- Nuts and Bolts Problem
- Count frequencies of elements
- Check if two arrays are equal or not
- First element to occur k times
- In First But Second
- Non-Repeating Element
- Group Anagrams Together
- Winner of an election
- Check for a pair with given sum
- Count distinct pairs with difference k
- Count pairs with given sum
- Find all four sum numbers
- A Simple Fraction
- Largest Fibonacci Subsequence
Related Learning Resources: Hashing Data Structure
Matrix Problems
- Transpose of Matrix
- Print Matrix in snake Pattern
- Print a given matrix in spiral form
- Is Sudoku Valid
- Count zeros in a sorted matrix
- A Boolean Matrix Question
- Search in row-wise and column-wise sorted
- Find the row with maximum number of 1s
- Count pairs Sum in matrices
- Median In a Row-Wise sorted Matrix
Related Learning Resources: Matrix Data Structure
- Print Pattern
- Tower of Hanoi
- Josephus problem
- Recursively remove all adjacent duplicates
- Possible words from Phone digits
- Flood fill Algorithm
- Permutations of a string
Related Learning Resources : Recursion
Divide & Conquer Problems
- Write your own power function
- Program for n-th Fibonacci Number
- K-th element of two sorted Arrays
- Median of two sorted arrays
- Karatsuba Algorithm
- The Painter’s Partition Problem
- Convex Hull
- Counting inversions
Related Learning Resources: Divide and Conquer Algorithms
Linked List Problems
- Print a Linked List
- Length of a linked list
- Node at a given index in linked list
- Middle of a linked list
- n-th node from end of a linked list
- Delete a node
- Remove every k’th node
- Delete N nodes after M nodes of a linked list
- Delete without head pointer
- Rearrange a linked list
- Segregate even and odd (Using only one traversal)
- Reorder List
- Polynomial Addition
- Insert in a Sorted List
- Swap nodes in pairs
- Reverse a linked list
- Reverse a Linked List in groups of given size.
- Flattening a linked list
- Get intersection point
- Remove duplicates from sorted list
- Remove duplicates from unsorted lists
- Sort a linked list of 0s, 1s and 2s.
- Circular Linked List
- Detect loop in a linked list
- Find length of Loop
- Remove loop in a linked list
- Add two numbers represented by linked lists
- Clone a linked list with random pointers
- Add 1 to a number represented as linked list
- Add two numbers represented as linked list
- Multiply two linked lists
- Merge two sorted linked lists
- Merge Sort on Linked List
- Intersection of Two Linked Lists
- Union of Two Linked Lists
Related Learning Resources: Linked List Data Structure
Doubly and Circular Linked Lists Problems
- Insert a node in Doubly linked list
- Delete node in Doubly Linked List
- Circular Linked List Traversal
- Split a Circular Linked List into two halves
- Insert in Sorted way in a Sorted DLL
- QuickSort on Doubly Linked List
- Merge Sort on Doubly Linked List
- Rotate doubly Linked List by P nodes
- XOR Linked List
- Doubly Linked List
Stack Problems
- Implement Stack using Array
- Implement Stack using Linked List
- Check for balanced parenthesis
- Reverse a stack
- Implement two stacks in an array
- Design a stack with getMin
- The celebrity problem
- Stock Span Problem
- Next Greater Element
- Next Smaller Element
- Longest valid Parentheses
Related Learning Resources: Stack Data Structure
Queue and Dequeue Problems
- Implement Queue using Linked List
- Implement Queue using Array
- Implement Stack using Queue
- Implement Queue using Stack
- Reversing a Queue
- Circular tour
- First non-repeating character in a stream
Related Learning Resources: Queue Data Structure
Prefix Sum and Sliding Window Problems
- Equilibrium Point
- Check if there is a subarray with 0 sun
- Longest Sub-Array with Sum K
- Longest subarray with sum divisible by K
- Largest subarray with equal 1s and 0s
- Longest common span with same number of 1s and 0s among two arrays
- Find mximum sum in any subarray of size k
- Count distinct elements in every window of size k
- Check for subarray with given sum
Related Learning Resources: Prefix Sum and Sliding Window
Bit Magic Problems
- Check if a number is even or odd.
- Number of bit flips
- Game of XOR
- Find bit at a position
- Swap odd and even bits
- Odd occurring element
- Missing number in array
- Index Of an Extra Element
- Reverse Bits
- Count set bits
Related Learning Resources: Bit Magic
Tree Problems
- Inorder Traversal
- Preorder Traversal
- Postorder Traversal
- Level order traversal
- Find height of Binary Tree
- Count Leaves in Binary Tree
- Check for Children Sum Property
- Mirror Tree
- Check for Balanced Tree
- Lowest Common Ancestor in a Binary Tree
- Diameter of Binary Tree
- Left View of Binary Tree
- Right View of Binary Tree
- Maximum path sum
- Level order traversal line by line
- Tree from Postorder and Inorder
- Tree from Preorder and Inorder
- Connect Nodes at Same Level
- Zig-Zag level order traversal
- Serialize and Deserialize a Binary Tree
- Leaves to DLL
- Binary Tree to Doubly Linked List
- Binary Tree to Circular Doubly Linked List
Related Learning Resources: Tree Data Structure
Binary Search Tree Problems
- Minimum in BST
- Inorder Traversal and BST
- Count BST nodes that lie in a given range
- Add all greater values
- Predecessor and Successor in BST
- Closest Neighbor in BST
- Lowest Common Ancestor in a BST
- Convert Level Order Traversal to BST
- Normal BST to Balanced BST
- Pair with given sum in BST
- Check for BST
- Correct BST with two nodes swapped
- Median of BST
- k-th smallest element in BST
- Unique BST’s
- Array to BST
- Preorder Traversal and BST
- Preorder to Postorder
- Leaf nodes from preorder traversal
- Triplet with 0 sum in BST
- Merge two BST ‘s
- Largest BST Subtree
Related Learning Resources: Binary Search Tree
Heap Problems
- Binary Heap Operations
- Height of Heap
- Sort a Nearly Sorted Array
- K Largest Elements
- K-th largest element in a stream
- Median of stream
- Merge k sorted arrays
Related Learning Resources: Heap Data Structure
Graph Problems
- Print adjacency list
- Breadth First Search
- Depth First Search
- Find whether path exist
- Knight Walk
- Snake and Ladder Problem
- Bipartite Graph
- Detect Cycle in an undirected graph
- Detect Cycle in a directed graph
- Find first n numbers with given set of digits
- Rotten oranges
- Topological sort
- Shortest Source to Destination Path
- Transitive closure of a Graph
- Strongly Connected Components
Related Learning Resources: Graph Data Structure
Greedy Algorithms Problems
- Fractional Knapsack
- Largest number with given sum
- Activity Selection
- N meetings in one room
- Minimum Platforms
- Minimum number of Coins
- Job Sequencing Problem
- Minimize the heights
- Huffman Coding
- Huffman Decoding
- Minimum Spanning Tree
- Dijkstra for Adjacency Matrix
Related Learning Resources: Greedy Algorithms
Dynamic Programming Problems
- Print first n Fibonacci Numbers.
- Count ways to reach the n’th stair
- Cutted Segments
- Kadane’s Algorithm
- Stickler Thief
- Minimum number of jumps
- Total Decoding Messages
- Min Cost Path
- Coin Change
- Longest Common Subsequence
- Consecutive 1’s not allowed
- Edit Distance
- Rod Cutting
- Water Overflow
- Maximum Tip Calculator
- Longest Increasing Subsequence
- Maximum sum increasing subsequence
- Max length chain
- 0 – 1 Knapsack Problem
- Interleaved string
- Longest Palindromic Subsequence
- Wildcard Pattern Matching
- Box Stacking
- Longest Bitonic subsequence
- Minimum sum partition
- Largest square formed in a matrix
- Matrix Chain Multiplication
- Special Keyboard
- Egg Dropping Puzzle
- Optimal Strategy for a Game
Related Learning Resources: Dynamic Programming
Backtracking Problems
- Rat Maze With Multiple Jumps
- Coins and Game
- Hamiltonian Path
- Solve the Sudoku
- Combination Sum – Part 2
- Combination Sum
- Largest number in K swaps
- M-Coloring Problem
- Black and White
Related Learning Resources: Backtracking
Trie Problems
- Trie Search and Insert
- Trie Delete
- Unique rows in a binary matrix
- Count of distinct substrings
- Word Boggle
Related Learning Resources: Trie Data Structure
Practice Questions to Test Your Overall Learning
Longest common prefix Implement Atoi Two numbers with sum closest to zero Smallest greater elements in whole array Max rectangle Find triplets with zero sum Counting elements in two arrays Merge K sorted linked lists Maximum Difference Circle of strings All possible Word Breaks Alien Dictionary Design a tiny URL or URL shortener Implement LRU Cache
Important Links
- Aptitude questions asked in round 1: Placements Course designed for this purpose.
- MCQs asked from different computer science subjects: Subject-Wise Quizzes
- Interview theory and coding questions of all companies : Company wise all practice questions .
- Interview experiences of all companies: Interview corner .
- Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe,
- Must Do Coding Questions Company-wise
Similar Reads
- Competitive Programming
- GFG-Practice
IMAGES
VIDEO