50 Coding Interview Practice Questions for Students
A structured practice list covering arrays, hashing, trees, graphs and dynamic programming.
By NextPeer Editorial · 3 min read
How to use this practice list
These are 50 practice prompts, not a verified ranking of questions asked by particular companies. Choose a few each week. State assumptions, write examples, attempt a solution, test edge cases and explain its complexity.
Arrays and strings
- Find the largest and second-largest distinct values in an array.
- Reverse an array in place.
- Move zeroes to the end while preserving other values' order.
- Find two numbers whose sum equals a target.
- Find the maximum sum of a contiguous subarray.
- Merge two sorted arrays.
- Rotate an array by k positions.
- Find the missing value from a sequence with a stated range.
- Check whether a string is a palindrome under specified rules.
- Find the longest common prefix of a list of strings.
Hashing and sliding windows
- Count the frequency of each value.
- Determine whether two strings are anagrams.
- Group a list of words by anagram signature.
- Find the first non-repeating character.
- Find the longest substring without repeated characters.
- Find the maximum sum of a fixed-length window.
- Find the shortest positive-integer subarray meeting a target sum.
- Detect duplicates within k indices of each other.
- Find the intersection of two arrays under stated duplicate rules.
- Find the longest consecutive integer sequence.
Linked lists, stacks and queues
- Reverse a singly linked list.
- Detect a cycle in a linked list.
- Find the middle node of a linked list.
- Merge two sorted linked lists.
- Remove the nth node from the end.
- Validate balanced brackets.
- Implement a queue using two stacks.
- Design a stack that also returns the minimum value.
- Find the next greater element for each array position.
- Evaluate an expression in reverse Polish notation.
Searching, trees and graphs
- Implement binary search and state its sorted-input assumption.
- Find the first and last position of a target in a sorted array.
- Search a rotated sorted array with distinct values.
- Compute the maximum depth of a binary tree.
- Traverse a binary tree level by level.
- Validate a binary search tree with a stated duplicate policy.
- Find the lowest common ancestor in a binary tree.
- Count connected components in an undirected graph.
- Find a shortest path in an unweighted graph.
- Detect a cycle in a directed graph.
Recursion, dynamic programming and design
- Generate all subsets of a set of distinct values.
- Generate all permutations of distinct values.
- Solve a combination-sum problem with a stated reuse policy.
- Count ways to climb stairs using one- or two-step moves.
- Find the minimum number of coins for a target amount.
- Find the length of the longest increasing subsequence.
- Find the longest common subsequence of two strings.
- Solve the house-robber problem for a linear sequence.
- Find the kth-largest value using an appropriate data structure.
- Design an LRU cache and explain its operations.
Review beyond the answer
For each solution, test small inputs, repeated values, boundary values and invalid inputs where relevant. Compare a straightforward approach with an improved one. Be ready to explain why your method is correct; memorised code alone will not help when the problem changes.
Put your learning into practice
Explore NextPeer training or download a free guide for your next study session.