HackIndia Logo
HackathonsNewsSkillsGrowth
HackIndia LogoContact: +91 9910125804

General

  • Companies
  • Colleges
  • Board of Advisors
  • Brand Ambassadors
  • FAQ
  • Contact
  • Report a Bug

Hackathons

  • Upcoming Hackathons
  • Judges
  • Mentors
  • Partners
  • Participating Colleges

Resources

  • About Us
  • Branding
  • Latest News
  • Growth
  • Skills
  • Ecosystem
  • Forum
  • Ideas
  • Prompt Optimizer

© 2026 HackIndia. All rights reserved.

Privacy PolicyTerms of ServiceCode of ConductSitemap
    HackIndia
    HackathonsNewsInternshipsSkillsGrowth
    ← AlgorithmsLesson 1 of 8 4 min

    Algorithms

    Big-O without fear

    • +10 XP for this lesson
    • +100 XP when the skill is proved
    • Nobody here has proved it yet
    In 30 seconds
    • Read Big-O as a rough growth rate, not a scary maths topic.
    • Compare two DSA solutions by time and space before coding.
    • Add complexity notes to each solved problem in your repo.

    Why Big-O matters

    In placement rounds, the interviewer is not only checking if your code works. They are checking if it still works when the input becomes large.

    Big-O is the short way to say how your time or memory grows as input size grows. It helps you choose a better approach before you waste time coding.

    Key point

    One idea

    Big-O ignores exact seconds and focuses on growth. Ask: if n doubles, does my work stay almost same, double, or become much worse?

    For interviews and your repo, mention both time complexity and space complexity for each solution.

    Skip to lesson 2 →
    Working towards
    Algorithms +100 XP

    0 of 8 lessons done · proved by a submitted project with a public repository

    See the track

    Common growth rates

    Use these as a placement cheat sheet. O(1) is constant work. O(log n) cuts the search area. O(n) scans once. O(n log n) is common in efficient sorting. O(n²) checks pairs. O(2ⁿ) often appears in brute force subsets.

    You do not need a proof in most interviews. You need a clear reason linked to loops, recursion, data structures, or sorting.

    Example

    Loop reading

    Read code like a cost meter. Count how many times the main operation runs as n grows.

    This example compares one scan with a pair check.

    def has_zero(nums):
        for x in nums:
            if x == 0:
                return True
        return False
    # Time: O(n), because in the worst case we scan every number.
    # Space: O(1), because we use no extra data structure.
    
    
    def has_pair_sum(nums, target):
        for i in range(len(nums)):
            for j in range(i + 1, len(nums)):
                if nums[i] + nums[j] == target:
                    return True
        return False
    # Time: O(n^2), because we check many pairs.
    # Space: O(1).
    Your to-do

    How to estimate

    Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.

    0 of 5 done

    Common mistake

    Do not average casually

    Beginners often say a search is O(1) because the answer may be found early. In interviews, start with worst-case unless asked otherwise.

    If the target is last or missing, a simple scan still checks every item. That is O(n).

    Tip

    Use AI carefully

    You can ask ChatGPT, Gemini, or Claude to review your complexity note. Paste only your function and ask: “Give time and space complexity. Explain using loops or data structures.”

    Check the answer yourself. AI often misses hidden costs like sorting, slicing, copying arrays, recursion stack space, or nested loops inside helper functions.

    Your to-do

    Do this now

    Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.

    0 of 5 done

    mkdir placement-dsa-practice
    cd placement-dsa-practice
    git init
    printf "Big-O notes\n" > complexity-notes.txt
    git add complexity-notes.txt
    git commit -m "add big-o notes"

    Quick check

    0 of 2 right
    1.Your code has two separate loops over the same array of n items. What is the time complexity?
    2.What should you include with each solved problem in your DSA repo?

    Answer the quick check to finish this lesson.