Foundations

The ideas everything else is built on: how to count the cost of code, how arrays and strings behave, how recursion unwinds, and how hashing finds things in one step. Each one has a live visualizer running the real code.

  1. 01Counting stepsBig-O by watching the counter: a loop inside a loop costs n².O(n²)
  2. 02Linear searchCheck every item in turn. The baseline every faster search is measured against.O(n)
  3. 03Rotating an arrayShift every item k places using three reversals and no extra array.O(n)
  4. 04Palindrome checkCompare a string from both ends inwards, one pair of letters at a time.O(n)
  5. 05RecursionA function that calls itself, with every waiting call shown on the stack.O(n)
  6. 06Hash tableTurn each key into a bucket number so lookups skip the search entirely.O(1) avg
  7. 07Finding duplicatesRemember what you have seen in a hash set and the n² check becomes n.O(n)