Module 2 · vector: The Container You Reach for First
CP and Interview Pack: vector Patterns, Questions and the Bug Gallery
ProReading
Codeforces Round 111 (Div. 2) opened with problem 160A, "Twins". You get n coins. Take as few as you can so that your share is strictly larger than what is left. Bob tried subsets in his head. Amara read the coins into a vector, sorted it and took the largest first. Her whole solution is pattern 1 below.
Checking what this lesson needs for you…
What is inside CP and Interview Pack: vector Patterns, Questions and the Bug Gallery
- Pattern 1: read n, then n values
- Pattern 2: a grid and its four neighbours
- Pattern 3: prefix sums, with the off-by-one handled
- Pattern 4: two pointers over a sorted vector
- Pattern 5: erase-remove
- Six interview questions, with model answers