Week 5 — DSA Pass 1 Done & Python Wrap-up

intermediate dsa python

Goal: “It does not matter how slowly you go as long as you do not stop.” — This is a BIG week — we’re closing out both DSA Pass 1 and Python. After this, DSA switches to practice mode and you’ll never have a week without coding problems again.

Topics

DayTrackFocusTopics
MonA — DSADynamic Programming1D DP Patterns · 2D DP Patterns · Knapsack Patterns · Interval and String DP · DP on Trees and Graphs
TueB — PythonAdvanced OOP & TypesMetaclasses · slots · Type Hints
WedA — DSAGreedy & PatternsGreedy Algorithms · Backtracking · Intervals · Binary Search on Answer · Common Interview Patterns
ThuB — PythonModern PythonWalrus Operator and Modern Features · Duck Typing and Protocols · Modules, Packages, and Imports
FriB — PythonBest Practices & Wrap-upPythonic Code and PEP8 · File Handling · Design Patterns · Common Output Questions

Key Concepts

  • DP is all about finding overlapping subproblems and optimal substructure. If we can break a problem into smaller versions of itself AND the subproblems repeat, DP is our friend. Start with recursion, add memoization, then convert to tabulation.
  • Greedy works when the local optimal choice leads to the global optimal — but we need to prove it (or at least intuit it). Activity selection and fractional knapsack are classic examples.
  • Backtracking is brute force with pruning. We explore choices, and the moment we realize a path won’t work, we back up. N-Queens and Sudoku are the poster children.
  • Metaclasses are “classes of classes” — rarely used in production but interviewers love asking about them. Know that type is the default metaclass and __new__ vs __init__ at the meta level.
  • __slots__ saves memory by preventing __dict__ creation on instances. Great for when we have millions of objects with a fixed set of attributes.

Practice

  • Solve 1 knapsack variant (0/1 knapsack or unbounded knapsack)
  • Solve 1 greedy problem (e.g., activity selection, jump game)
  • Solve 1 backtracking problem (N-Queens or generate parentheses)
  • Try 3 Python output questions — predict the output before running
  • Write a class using __slots__ and compare memory usage with a regular class

~20 topics · ~2 hrs/day · Milestone week: DSA Pass 1 ✓ · Python ✓