Use this 50-question checklist to identify gaps in your coding practice. It is a study selection, not a claim about question frequency or a prediction of any employer's interview. The worked examples after the checklist show how to explain a solution, test its assumptions, and account for its cost.

Arrays and strings (questions 1–10)

  1. Find the maximum subarray sum (Kadane's algorithm)
  2. Rotate an array by K positions
  3. Find all pairs in an array that sum to a target value
  4. Find the first non-repeating character in a string
  5. Check if a string is an anagram of another
  6. Merge two sorted arrays in O(1) extra space
  7. Move all zeroes to the end of an array without changing relative order
  8. Find the longest common prefix among a list of strings
  9. Implement strStr (find a substring in a string)
  10. Count the frequency of each character in a string

Linked lists (questions 11–18)

  1. Reverse a linked list iteratively and recursively
  2. Detect a cycle in a linked list (Floyd's algorithm)
  3. Find the middle node of a linked list in one pass
  4. Merge two sorted linked lists
  5. Remove the Nth node from the end of a list
  6. Add two numbers represented as linked lists
  7. Flatten a multilevel doubly linked list
  8. Clone a linked list with a next and random pointer

Stacks and queues (questions 19–24)

  1. Implement a stack using two queues
  2. Evaluate a postfix expression
  3. Find the largest rectangle in a histogram
  4. Implement a queue using two stacks
  5. Next greater element for every array element
  6. Minimum stack: design a stack that retrieves the minimum in O(1)

Trees and binary search trees (questions 25–33)

  1. Level-order traversal of a binary tree
  2. Check if a binary tree is height-balanced
  3. Find the lowest common ancestor of two nodes
  4. Serialize and deserialize a binary tree
  5. Validate a binary search tree
  6. Find the Kth smallest element in a BST
  7. Convert a sorted array to a balanced BST
  8. Diameter of a binary tree
  9. Right side view of a binary tree

Graphs (questions 34–40)

  1. BFS and DFS implementation with adjacency list
  2. Detect a cycle in a directed graph
  3. Topological sort of a DAG
  4. Find all connected components in an undirected graph
  5. Shortest path in an unweighted graph (BFS)
  6. Number of islands (2D grid BFS/DFS)
  7. Check if a graph is bipartite

Hashing (questions 41–44)

  1. Find the first duplicate element in an array
  2. Longest consecutive sequence in an unsorted array
  3. Group anagrams together from a list of strings
  4. Two-sum using a hashmap in O(n)

Dynamic programming (questions 45–50)

  1. Fibonacci number using memoization and bottom-up DP
  2. 0/1 knapsack problem
  3. Longest common subsequence
  4. Coin change problem (minimum coins)
  5. Longest increasing subsequence
  6. Edit distance between two strings

How to approach DSA questions in interviews

When given a coding problem in an interview:

  • Ask one or two clarifying questions about constraints and edge cases
  • State your brute-force approach first, then identify the optimisation
  • Write pseudocode before actual code if the problem is complex
  • Think out loud throughout — interviewers score the process, not just the answer
  • Always discuss time and space complexity at the end

Practise at least ten problems from each category above. Track your solve times and revisit problems you could not solve within 25 minutes. Consistent daily practice over four to six weeks is the most reliable path to interview-day confidence.

How to study these questions

For each structure, write down its invariant, common operations, and the trade-off that makes it useful. Implement a small example without looking at a reference, then test an empty input, a duplicate, and a large input. In an interview, choose the structure because it supports the operation the problem needs, not because it is fashionable. Explain complexity after checking it and mention an alternative when the constraints could change. This turns a question list into durable problem-solving knowledge.

Worked example: maximum subarray without losing all-negative cases

Given [-2, 3, -1, 4, -6], find the largest sum of a non-empty contiguous subarray. Enumerating every start and end and repeatedly summing the range is unnecessary. At each position, the best subarray ending here either extends the previous one or starts at the current value.

Initialise both current and best to the first element, not zero. Processing the remaining elements gives current values 3, 2, 6, and 0; best becomes 6, from [3, -1, 4]. Initialising best to zero would incorrectly return zero for [-5, -2], even though an empty subarray is forbidden.

function maxSubarray(values) {
  if (values.length === 0) throw new Error("Expected a non-empty array");
  let current = values[0];
  let best = current;
  for (let i = 1; i < values.length; i++) {
    current = Math.max(values[i], current + values[i]);
    best = Math.max(best, current);
  }
  return best;
}

Test [7] -> 7, [-5, -2] -> -2, and [0, 0] -> 0. The loop visits each value once, so time is O(n), with O(1) extra space. If asked for the indices, track where a new subarray starts and copy that start whenever best improves. Ask how ties should be resolved before choosing a rule.

Worked example: two-sum and duplicate values

For [3, 3] and target 6, the answer uses two different indices. Store previously visited values in a map. Before inserting the current value, look for target minus current. That ordering prevents a single element from matching itself.

function twoSum(values, target) {
  const seen = new Map();
  for (let i = 0; i < values.length; i++) {
    const needed = target - values[i];
    if (seen.has(needed)) return [seen.get(needed), i];
    seen.set(values[i], i);
  }
  return null;
}

For [2, 7, 11] and target 9, index zero stores 2; index one finds the required 2 and returns [0, 1]. For [3] and target 6, no earlier 3 exists, so the result is null. Test negative numbers and no-solution inputs as well. Assuming average constant-time map operations, this takes O(n) expected time and O(n) space. It returns one pair, not all pairs. The checklist's all-pairs problem needs a separate decision about duplicate pairs and output format.

Worked example: shortest paths in an unweighted graph

Suppose A connects to B and C, B connects to D, and C also connects to D. Starting at A, breadth-first search discovers B and C at distance one and D at distance two. Mark a vertex visited when you enqueue it; otherwise B and C can both enqueue D. Store a parent when first discovering a vertex if the question asks for the route, not just its length.

Use an array with a moving head index for a JavaScript queue instead of repeatedly shifting the array. With adjacency lists, each reachable vertex and its incident edges are processed, giving O(V + E) time and O(V) auxiliary space. An unreachable vertex has no finite distance from the starting point. This method does not solve arbitrary weighted shortest paths: fewer edges need not mean lower total weight.

Check your understanding before moving on

For each solution, write the input contract and three tests before coding. Then explain the invariant: current is the best sum ending at this index; seen contains only earlier positions; a BFS queue processes vertices in distance order. If you cannot explain why an invariant stays true, revisit that step rather than memorising code.

As an extension, change exactly one requirement: return subarray indices, return all two-sum pairs, or reconstruct the graph route. Record what changes in correctness, output size, and memory use. These exercises expose more understanding than simply recognising an algorithm name.