Repaso
Español
Algorithms & DSCoreALG-35

How do you approach a coding problem you have never seen in an interview?

Answer

  • Restate the problem; ask about input size, constraints and edge cases (empty input, duplicates, negatives).
  • Work through 1-2 small examples by hand.
  • Describe a brute-force solution and its complexity first.
  • Look for patterns: hash map, two pointers, sliding window, sorting, heap, BFS/DFS, DP, binary search.
  • Agree on the approach, then code cleanly with clear names, thinking aloud.
  • Test with your examples and edge cases; trace the code line by line.
  • State the final time and space complexity and possible improvements.

Key terms

Practice this question in Repaso