Stack Bash - Master data structures and algorithms

DSA in the AI era

AI can write a first draft of a solution in seconds. That doesn't mean you can skip data structures and algorithms.
In an interview, you still need to pick an approach, talk about time and space, and write code that actually works.
The starter code in the problems below looks finished. It's almost right. Your job is to read it carefully, run the tests, and fix what's wrong.

What still matters

Same things as before:
  1. Pick a data structure on purpose. An array and a hash table solve different problems.
  2. Know the Big O. A nested loop is O(n2). A single pass is O(n).
  3. Check the edge cases. Empty input, one element, duplicates, a target that isn't there.
Tip: If you can't explain a line of code, don't ship it. Interviewers will ask about that line anyway.

Common bugs

AI drafts usually fail in small ways. They look like working code.
  • Using s in t when you needed a subsequence, not a substring
  • Forgetting to fill the rest of the array with zeroes
  • Scanning from the end when the prompt asked for the first unique character
  • Grouping anagrams with set(word), which drops how many times a letter appears
  • A loop for a recurrence that runs one extra time
None of these are syntax errors. The easy cases often still pass.

How to check a draft

  1. Restate the prompt in your own words
  2. Trace the code with the example in the prompt
  3. Run the tests
  4. Try one extra case the draft probably skipped
  5. Say the time and space complexity out loud
There's a short Python for interviews recap next, then two small Python exercises, then these problems:
After this chapter, continue with Big O.

7 Essential DSA in the AI era Coding Interview Problems

Master DSA in the AI era by trying the coding challenges below.
  1. 1.Count occurrencesEasy
  2. 2.Fix the default listEasy
  3. 3.Move zeroesEasy
  4. 4.Is subsequenceEasy
  5. 5.First unique characterEasy
  6. 6.Group anagramsMedium
  7. 7.Climb stairsEasy