Goal: Refresh Python fundamentals + interview patterns the way FAANG expects ML engineers to code.
Outcome: Students can write clean, efficient, interview-ready Python and explain tradeoffs (time/space, data structure choice, gotchas).
- Fork this repository.
- Open
python_refresher_student_lab.ipynbin Google Colab. - Complete all TODO sections.
- Restart runtime → Run All cells.
- Push changes and submit a Pull Request.
- ❌ No “works on my machine” code (write deterministic tests)
- ✅ Always analyze time & space complexity
- ✅ Prefer a clean baseline first, then optimize
- ✅ Handle edge cases explicitly
- ✅ Use the right data structure (dict/set/heap/deque)
- External libraries (unless explicitly imported)
- ML model training
- Do NOT rename the notebook
- Do NOT delete TODOs
- Do NOT hardcode outputs
- Notebook must run top-to-bottom
- Synthetic Python inputs only
- Mirrors FAANG interview settings
- Forces focus on algorithm + complexity
Create (without unnecessary loops):
- Squares of even numbers from 1..20
- List of (x, x²) for x=1..10
- Flatten a nested list
Checkpoint Questions:
- When do generator expressions beat list comprehensions?
- Why can Python-level loops be slower?
- Count characters in a string
- Extract top-k most common
Interview Angle:
Countervs sorting (time complexity)- When is hashing a bottleneck?
- Group words by first letter
- Build nested groupings
FAANG Gotcha:
- Difference between basic slicing vs “missing key” errors in dict
- O(n) one-pass hash map
Checkpoint Questions:
- Why does the order “check complement then insert” matter?
- What breaks if duplicates exist?
- Maintain a moving window with an invariant
Checkpoint Questions:
- What is the window invariant?
- Why is the algorithm O(n) and not O(n²)?
- No division
- O(n)
Interview Angle:
- Why does it handle zeros naturally?
FAANG Gotcha:
- Explain why deque ops are amortized O(n)
FAANG Gotcha:
- O(1)
get/putrequires both structures
Students must submit:
- Clean notebook (runs top-to-bottom)
- Short answers for each Checkpoint/Explain block
- Complexity notes for each core problem
| Skill | Evaluated |
|---|---|
| Data structure choice | ✅ |
| Complexity reasoning | ✅ |
| Edge-case coverage | ✅ |
| Correctness & invariants | ✅ |
| Code clarity | ✅ |
| Communication (explanations) | ✅ |
- Merge K Sorted Lists (heap)
- Validate Parentheses (stack)
- Implement
topKFrequentwith heap vs bucket sort