0Pricing
Coding Interview Prep · Lesson

Counting Operations with Big-O

From constant to quadratic in plain terms.

Counting Operations with Big-O is a free Coding Interview Prep lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Coding Interview Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Count Operations

In contests, speed wins. Instead of timing your code, you estimate how many steps it takes. That estimate is its time complexity. 🚀

Meet Big-O

Big-O describes how the operation count grows as the input size n grows. It ignores small details and focuses on the dominant trend.

Constant Time O(1)

When the work never depends on n, it is O(1). Reading one list element or doing one addition always takes the same time.

x = arr[0]
y = a + b

Linear Time O(n)

One simple loop over n items is O(n). Double the input and you roughly double the work. This is the everyday workhorse.

for x in arr:
    total += x

Quadratic Time O(n squared)

A loop inside a loop over n items is O(n^2). For n = 1000 that is a million steps, and it grows fast from there.

for i in range(n):
    for j in range(n):
        check(i, j)

Logarithmic Time O(log n)

When each step halves the problem, you get O(log n). Binary search reaches a billion items in only about 30 steps. ✨

The Growth Ladder

From fastest to slowest the common order is: O(1), O(log n), O(n), O(n log n), O(n^2). Higher up means it scales better.

Drop the Constants

Big-O ignores constant factors, so O(2n) is just O(n). Two passes still grow linearly, so the multiplier does not change the class.

Keep Only the Biggest Term

When terms add up, only the fastest-growing one counts. O(n^2 + n) simplifies to O(n^2) because n^2 dwarfs n as n grows.

Sequential vs Nested

Two loops one after another add up to O(n + n) = O(n). Two loops nested multiply to O(n^2). The shape of the loops tells you which.

Worst Case First

Contests judge on the hardest test, so you reason about the worst case. Assume the loop runs fully, not that it returns early.

Quick Check

Time to test your Big-O instincts.

Recap

You now read code as growth: O(1), O(n), O(n^2), and O(log n). Drop constants, keep the biggest term, and think worst case. 🎯

Frequently asked questions

Is the “Counting Operations with Big-O” lesson free?

Yes — the full text of “Counting Operations with Big-O” is free to read here on the web, and the Coding Interview Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Coding Interview Prep course, upgrade to CoddyKit PRO.

What will I learn in “Counting Operations with Big-O”?

From constant to quadratic in plain terms. You practise Coding Interview Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Coding Interview Prep?

No prior experience is required. Coding Interview Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Counting Operations with Big-O” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Coding Interview Prep lesson?

Yes. Every Coding Interview Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Counting Operations with Big-O
  2. The 10^8 Rule of Thumb
  3. Read Constraints, Pick Complexity
  4. Why TLE Happens and How to Spot It
← Back to Coding Interview Prep