Skip to main content
📜 WAYPOINT LESSON

Checkpoint — Two Pointers

⭐ beginner⏳ 15 min read📍 Lesson 51 of 281

Pass the graded problem to finish the two-pointers module.

Checkpoint — hai con trỏ. Pass the graded challenge below — it is the classic at-most-k-distinct window: expand r, shrink l while distinct types exceed k, track r - l + 1. The graded near-misses: shrinking only once per step (l falls behind and the window stays invalid), and counting types with a scan instead of a frequency array (O(n) per step = TLE at n = 2*10^5).

Điểm kiểm tra — hai con trỏ. Pass bài chấm bên dưới — bài kinh điển cửa-sổ-tối-đa-k-loại: mở rộng r, thu l trong khi số loại vượt k, theo dõi r - l + 1. Các near-miss bị chấm: chỉ thu một lần mỗi bước (l tụt lại và cửa sổ giữ trạng thái bất hợp lệ), và đếm loại bằng quét thay vì bảng tần suất (O(n) mỗi bước = TLE tại n = 2*10^5).