Skip to content

Introduction to DSA with Python

Welcome to the DSA with Python track — a complete, hands-on path from “what is Big-O?” all the way to segment trees and max-flow. It is built for two goals that overlap more than people think:

  • Cracking big-tech interviews (FAANG-style problem solving).
  • Competitive programming (LeetCode, Codeforces, contests).

What you’ll learn

  • What data structures and algorithms actually are, and why they decide whether your code runs in 0.1 s or times out.
  • How to run and solve problems right here in the browser — no setup.
  • A repeatable way to read a problem, spot the pattern, and reach for the right tool.
  • The full toolkit: arrays → trees → graphs → dynamic programming → advanced CP.

Why DSA matters

An algorithm is a step-by-step recipe. A data structure is how you organize data so an algorithm can be fast. Pick the wrong structure and even a correct algorithm is too slow to pass.

The same task — “is xx in this collection?” — costs wildly different amounts depending on the structure:

StructureMembership checkOrdered?
listlistO(n)O(n)keeps insertion order
setset / dictdictO(1)O(1) averageno (dict keeps insertion order, set doesn’t)
sorted listlist + binary searchO(logn)O(\log n)yes

That single choice — listlist vs setset — is the difference between Accepted and Time Limit Exceeded on a large input.

The roadmap

This track is organized into ordered phases. Follow them top-to-bottom, or jump to a phase you need.

diagram DSA with Python — learning roadmap mermaid

How to use this track

Every code block on this site is live. It runs real Python in your browser (via Pyodide) — click Run to execute, edit the code, and re-run. Try it:

hello_dsa.py
# Edit me, then press Run.
nums = [5, 3, 8, 1, 9, 2]
 
# Two ways to find the max — one is O(n), one hides a sort at O(n log n).
print("max via built-in:", max(nums))
print("sorted[-1]     :", sorted(nums)[-1])
hello_dsa.py
# Edit me, then press Run.
nums = [5, 3, 8, 1, 9, 2]
 
# Two ways to find the max — one is O(n), one hides a sort at O(n log n).
print("max via built-in:", max(nums))
print("sorted[-1]     :", sorted(nums)[-1])

You’ll also see three other block types throughout the track:

  • p5p5 animation panels — watch an algorithm move (sorting, BFS, DP fills).
  • mermaidmermaid diagrams — trees, graphs, and recursion structure.
  • Graded exercises — small tasks that check your answer instantly.

A first taste of “which structure?”

Below is a classic interview warm-up: does the array contain a duplicate? The naive double loop is O(n2)O(n^2). A setset makes it O(n)O(n). Fill in the blank to use a set.

Recap

  • Data structure = how data is organized; algorithm = what you do with it.
  • The right structure turns a slow solution into a fast one — often O(n)O(n) vs O(n2)O(n^2).
  • Every code block here is runnable; edit and experiment freely.

Next: Setup for CP & interviews — accounts, tooling, and how to practice.

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did