Common DSA Mistakes and How to Avoid Them
14 March 2026•2 min read
Off-by-One and Index Errors
- Binary search:
mid = (lo + hi) / 2can overflow; uselo + (hi - lo) / 2. Checklo <= hivslo < hiand 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.