Checkpoint — Debugging
Pass the graded problem to finish the debugging module.
Checkpoint — gỡ lỗi. Pass the graded challenge below. The bug is
a monotone pointer reused across queries — correct only when queries
arrive in ascending order. Two honest fixes: reset the pointer per
query (O(nq), fine at these constraints) or answer each query with
binary search / lower_bound (O(log n) per query). The graded
near-misses: keeping the shared pointer, and counting with <= (the
boundary test with equal values catches both).
Điểm kiểm tra — gỡ lỗi. Pass bài chấm bên dưới. Bug là một con trỏ
đơn điệu dùng chung qua các truy vấn — chỉ đúng khi truy vấn đến theo
thứ tự tăng. Hai cách sửa chính trực: reset con trỏ theo từng truy vấn
(O(nq), ổn với giới hạn này) hoặc trả lời mỗi truy vấn bằng tìm kiếm
nhị phân / lower_bound (O(log n) mỗi truy vấn). Các near-miss bị chấm:
giữ con trỏ dùng chung, và đếm bằng <= (test biên với giá trị bằng
bắt được cả hai).