Back to blog

Common DSA Mistakes and How to Avoid Them

14 March 20262 min read

Off-by-One and Index Errors

  • Binary search: mid = (lo + hi) / 2 can overflow; use lo + (hi - lo) / 2. Check lo <= hi vs lo < hi and when to return.
  • Array bounds: 0-indexed vs 1-indexed; check loop start and end.

Complexity Analysis

  • Claiming O(1) when you have a loop. Count nested loops and recursive calls.
  • Saying "hash map lookup is O(1)" without noting worst-case O(n) for collisions. Usually assume average O(1).

Not Clarifying the Problem

  • Input range: size of array, value range. Can you modify the array?
  • Output: single answer or all? Sorted or any order?
  • Edge cases: empty input, one element, duplicates.

Coding Too Fast

  • Think of a simple example and walk through your algorithm first.
  • Write pseudocode or main steps before coding.
  • Test with a small example before saying "done."

Summary

Slow down, clarify, check indices and bounds, and state complexity clearly. Use Preplume(/) to practice under timed conditions and build good habits.

Related posts

Most Asked Amazon DSA Questions

High-frequency DSA questions reported in Amazon interviews: arrays, trees, graphs, and design.

13 Mar 20262 min readRead more