Practice · 2 of 3
Overflow Smell
CHALLENGE
Difficulty: advanced+25 XP
**Scenario.** You must count pairs i < j in an array of n = 100000 elements; the count can reach ~5·10^9. Your comparator uses a - b < 0 on values up to 10^9. What is the primary risk?
**Which approach is the best fit? The program only needs to print the letter.**
**A)** Neither — int handles 5·10^9 fine on 64-bit judges
**B)** The count needs int64 (long long), and the subtracting comparator can overflow int
**C)** Only the comparator is wrong; the count fits int
**D)** Both are fine; overflow is only a Java problem
Press Submit to check your solution.
Back to lesson: Practice: Process Drills