Most Asked Coding Problems
High-frequency coding, DSA, OOP, and logic puzzles that keep showing up across software house interviews — ranked by how often companies ask them.
23 problems
- 1
Second largest or third largest element in an array
ArraysDSAMediumGiven an unsorted array of numbers, find the second-largest or third-largest value without simply sorting the entire array — usually expected to be solved in a single pass through the array.
Asked in 16 companies+11 - 2
Implement a Queue using one or two Stacks
Stacks & QueuesDSAMediumDesign a Queue data structure (First-In-First-Out order) using only Stack operations (Last-In-First-Out order) — implement both enqueue (push) and dequeue (pop) operations correctly.
Asked in 16 companies+11 - 3
Explain and write sorting algorithms
SortingDSAMediumExplain how common sorting algorithms work (Bubble Sort, Selection Sort, Merge Sort, Quick Sort), along with their time complexities, and sometimes write the actual code for one of them.
Asked in 15 companies+10 - 4
Check if a string is a palindrome
StringsDSAEasyGiven a string, determine whether it reads the same forwards and backwards (e.g. 'racecar' is a palindrome, 'hello' is not).
Asked in 13 companies+8 - 5
The Diamond Problem
OOPMediumA classic OOP concept: when a class inherits from two classes that both inherit from a common base class, ambiguity arises about which inherited method version to use. Explain the problem and how different languages solve it.
Asked in 11 companies+6 - 6
Detect and remove a loop (cycle) in a linked list
Linked ListDSAMediumGiven a linked list, determine whether it contains a cycle (a node's 'next' pointer eventually points back to an earlier node instead of null), then explain or write code to remove that cycle.
Asked in 10 companies+5 - 7
Binary Search
ArraysDSAEasyGiven a sorted array and a target value, find the index of that value efficiently by repeatedly halving the search range, instead of checking each element one by one.
Asked in 9 companies+4 - 8
Delete a specific node from a linked list
Linked ListDSAMediumGiven a pointer to a node inside a linked list (sometimes without access to the head), remove that node while keeping the rest of the list intact.
Asked in 9 companies+4 - 9
Check if two strings are anagrams of each other
StringsDSAEasyGiven two strings, determine whether one can be rearranged to form the other (e.g. 'listen' and 'silent').
Asked in 8 companies+3 - 10
Two Sum problem
ArraysDSAMediumGiven an array of numbers and a target sum, find a pair of numbers that add up to the target — ideally in a single pass through the array.
Asked in 7 companies+2 - 11
BFS and DFS traversal
TreesGraphsDSAMediumExplain and/or implement Breadth-First Search and Depth-First Search — the two standard ways of visiting all the nodes of a tree or a graph.
Asked in 8 companies+3 - 12
Reverse a linked list
Linked ListDSAEasyGiven a linked list, reverse the direction of all its pointers so the last node becomes the first node and vice versa.
Asked in 7 companies+2 - 13
Find the middle node of a linked list
Linked ListDSAEasyGiven a linked list, find its middle node — usually in a single pass, using a slow pointer and a fast pointer moving at different speeds.
Asked in 7 companies+3 - 14
Find the missing number in an array
ArraysDSAEasyGiven an array that should contain all numbers from 1 to N but is missing exactly one, find the missing number.
Asked in 7 companies+4 - 15
The jug/water-measuring puzzle
PuzzlesMediumA classic logic puzzle: given two jugs of different fixed capacities (commonly 3L and 5L, no markings), figure out a pouring sequence to measure an exact amount (commonly 4L).
Asked in 7 companies+2 - 16
The rope-burning puzzle
PuzzlesMediumA classic logic puzzle: ropes that each take exactly 1 hour to burn completely (can be lit from either end, don't burn uniformly). Use this to measure exactly 45 minutes.
Asked in 7 companies+2 - 17
The cake-cutting puzzle
PuzzlesEasyA classic logic puzzle: cut a cake into exactly 8 equal pieces using only 3 straight cuts.
Asked in 6 companies+1 - 18
Check whether a number is prime
MathDSAEasyWrite a function that determines whether a given number is prime (only divisible by 1 and itself).
Asked in 6 companies+2 - 19
Calculate factorial of a number
RecursionDSAEasyWrite a function (often using recursion) that calculates the factorial of a given number.
Asked in 6 companies+1 - 20
Flatten a nested or jagged array
ArraysDSAMediumGiven an array containing other arrays nested at various levels, convert it into a single flat (one-dimensional) array — usually without built-in library functions, often using recursion.
Asked in 5 companies+2 - 21
The weighing-balls puzzle
PuzzlesMediumA classic logic puzzle: among identical-looking balls, one is heavier or lighter than the rest — identify the odd ball using a balance scale in the fewest weighings.
Asked in 4 companies+1 - 22
Fibonacci sequence
RecursionDSAEasyWrite a function (often using recursion) that generates or returns the Nth number in the Fibonacci sequence.
Asked in 3 companies+1 - 23
Rotate or shift an array
ArraysDSAEasyGiven an array and a number of positions, shift or rotate the elements of the array by that many positions.
Asked in 2 companies