NextPeer Logo

NextPeer

Interview Preparation

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

  1. Find the largest and second-largest distinct values in an array.
  2. Reverse an array in place.
  3. Move zeroes to the end while preserving other values' order.
  4. Find two numbers whose sum equals a target.
  5. Find the maximum sum of a contiguous subarray.
  6. Merge two sorted arrays.
  7. Rotate an array by k positions.
  8. Find the missing value from a sequence with a stated range.
  9. Check whether a string is a palindrome under specified rules.
  10. Find the longest common prefix of a list of strings.

Hashing and sliding windows

  1. Count the frequency of each value.
  2. Determine whether two strings are anagrams.
  3. Group a list of words by anagram signature.
  4. Find the first non-repeating character.
  5. Find the longest substring without repeated characters.
  6. Find the maximum sum of a fixed-length window.
  7. Find the shortest positive-integer subarray meeting a target sum.
  8. Detect duplicates within k indices of each other.
  9. Find the intersection of two arrays under stated duplicate rules.
  10. Find the longest consecutive integer sequence.

Linked lists, stacks and queues

  1. Reverse a singly linked list.
  2. Detect a cycle in a linked list.
  3. Find the middle node of a linked list.
  4. Merge two sorted linked lists.
  5. Remove the nth node from the end.
  6. Validate balanced brackets.
  7. Implement a queue using two stacks.
  8. Design a stack that also returns the minimum value.
  9. Find the next greater element for each array position.
  10. Evaluate an expression in reverse Polish notation.

Searching, trees and graphs

  1. Implement binary search and state its sorted-input assumption.
  2. Find the first and last position of a target in a sorted array.
  3. Search a rotated sorted array with distinct values.
  4. Compute the maximum depth of a binary tree.
  5. Traverse a binary tree level by level.
  6. Validate a binary search tree with a stated duplicate policy.
  7. Find the lowest common ancestor in a binary tree.
  8. Count connected components in an undirected graph.
  9. Find a shortest path in an unweighted graph.
  10. Detect a cycle in a directed graph.

Recursion, dynamic programming and design

  1. Generate all subsets of a set of distinct values.
  2. Generate all permutations of distinct values.
  3. Solve a combination-sum problem with a stated reuse policy.
  4. Count ways to climb stairs using one- or two-step moves.
  5. Find the minimum number of coins for a target amount.
  6. Find the length of the longest increasing subsequence.
  7. Find the longest common subsequence of two strings.
  8. Solve the house-robber problem for a linear sequence.
  9. Find the kth-largest value using an appropriate data structure.
  10. 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.

Continue Reading

Back to all articles