Arrays & Strings
Work with Python lists, strings and 2D grids while knowing what each operation costs, and transform data in place.
4 objectives 6 steps about 120 min
Learn it step by step
Read the lessons in order, try the practice checks, then prove the skill with the knowledge check.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- State the cost of common list and string operations (index, append, insert at front, slice, concatenate, membership test) and pick the cheaper alternative.
- Implement in-place array transformations (reverse, rotate, partition, remove duplicates from sorted input, cyclic placement of values 1..n at their own index) using O(1) extra space.
- Build and compare strings efficiently, using join instead of repeated concatenation and character counts instead of repeated scans.
- Traverse 2D grids by rows, columns, diagonals and neighbors without index errors.
Lesson plan
6 steps, about 120 min · 5 of 5 lessons available so far
- How a Python List Grows Concept · 20 min
- A Cost Table for Lists and Strings Concept · 15 min
- In-Place Moves: Reverse, Rotate, Partition, Cyclic Sort Worked example · 30 min
- Building Strings Without Quadratic Traps Worked example · 15 min
- Lab: Grid Walks and Matrix Rotation Lab · 25 min
- Check: Array and String Drills Knowledge check · 8 questions
Practise it
Implement rotate-by-k in place, run-length string compression, in-place 90-degree rotation of an n x n matrix, and finding the missing and duplicated values in a list of 1..n by cyclic placement; pass the provided pytest suite, including empty and single-element cases.
Build it from scratch
Practice builds that exercise this skill by re-creating a real technology.
- Build your own Text EditorIntermediate · 10–20 h
- Build your own Template EngineIntro · 4–8 h
- Build your own JSON ParserIntro · 3–6 h
- Build your own Regex EngineIntermediate · 6–12 h
References
Hard prerequisites
Unlocks
On these roadmaps
Progress and evidence for this skill are shared across all of them.