🏆 Phase 6 · Competitive Programming
🟣 Final Checkpoint Quiz
MODULE 26 · FINAL LESSON
Competitive Programming Practice
Your progress in Phase 6 — Competitive Programming100%
🎯 What this checkpoint covers: This is the final lesson of C++ Mastery — a 12-question practice quiz reviewing Lessons 24 and 25 (I/O optimization, binary search, and the two-pointer technique), plus a few practical questions on picking the right complexity and the right STL function under judge time limits. Skim the recap below, then take the quiz.
Recap
Phase 6 in a Nutshell
Before the quiz, here's a compressed recap of the two lessons that make up Phase 6. If any of these points feel unfamiliar, it's worth a quick re-read of that lesson before you continue.
24
Lesson 24 — Input/Output Optimization
ios_base::sync_with_stdio(false); and cin.tie(NULL); at the top of main() remove the overhead of keeping C++ streams synced with C's stdio. '\n' beats endl in loops because endl forces a buffer flush on every call. scanf/printf are a faster but less type-safe alternative — never mix them with cin/cout after desyncing.25
Lesson 25 — Common CP Algorithms
Binary search finds a value in a sorted array in
O(log n) by halving the search space each step; std::lower_bound/upper_bound/binary_search from <algorithm> give you tested versions. The two-pointer technique solves problems like pair-sum search or in-place duplicate removal in a single O(n) pass, using two indices instead of a nested loop.🧩 Competitive Programming Checkpoint — 12 Questions
Answer all 12 questions to test your mastery of Phase 6 — and finish the course. Instant feedback on every answer.
1. What does
ios_base::sync_with_stdio(false) do?2. Why is repeated use of
std::endl inside a loop that prints thousands of lines a bad idea in CP?3. Why does
scanf("%d", &x) need &x — the address of the variable?4. What is the time complexity of binary search on a sorted array of n elements?
5. Binary search only produces correct results if the input array is:
6. What does
std::upper_bound(arr.begin(), arr.end(), x) return?7. What is the time complexity of the two-pointer technique scanning a sorted array once, with two indices moving toward each other?
8. In the slow/fast two-pointer pattern used to remove duplicates from a sorted array in-place, how much extra memory does the algorithm use beyond the original array?
9. You only need to know whether a value exists in a sorted vector, not its position. Which STL call is the most direct fit?
10. You need to count how many times a value appears in a sorted vector, without scanning it manually. What's the idiomatic approach?
11. A solution reads 10⁶ integers with
cin one at a time and prints results inside a loop using endl. It gets Time Limit Exceeded even though the logic is correct. What's the most likely fix?12. You have an unsorted array and want to find a pair summing to a target, faster than the O(n²) brute-force nested loop, using the two-pointer technique. What must you do first?
Finished the checkpoint?
Mark it complete to finish the course.
Module 26 of 26
Phase 6 — Competitive Programming