Topic 1 of 20
Big-O, complexity analysis and the basic math every later topic leans on.
Before you learn any clever technique, learn to measure code. Big-O notation describes how an algorithm's running time or memory grows as its input grows. It ignores constants and focuses on the dominant term, so a loop over n items is O(n) and a loop inside a loop is O(n²). Interviewers expect you to state the time and space complexity of every solution you write, and to know when a brute force is "fast enough" (roughly 10⁸ simple operations per second is a good rule of thumb).
The problems in this topic are deliberately simple. Use them to build habits: read the constraints first, write the brute force, state its complexity, then ask "can I do better?". You will also practise the small arithmetic tricks, extracting digits with % 10 and / 10, and guarding against integer overflow, that appear again and again in later topics.
Solve each one, then write its complexity in your notes before moving on. That single habit is what separates candidates who "solved it" from candidates who can explain it.
The classic warm-up: turns a spec into clean conditional logic and shows O(n) at its simplest.
Two nested loops over a grid: the gentlest possible introduction to O(m·n) analysis.
Reversing half the digits with % and / is a trick reused in many number problems.
Adds 32-bit overflow detection to digit reversal, a detail interviewers love to probe.
Shows how a smarter algorithm turns O(n·√n) into O(n log log n); a first taste of optimisation.