Question
Which practice avoids a common mistake with Deque for Sliding Window Maximum?
- Ignore the Deque for Sliding Window Maximum issue and rely on team discipline instead of APIs or contracts.
- Silence the Deque for Sliding Window Maximum problem by using raw types, broad catches, or shared mutable state.
- Do not forget to evict indices that fall out of the window before trusting the front element as the answer.
- Prefer the version of Deque for Sliding Window Maximum that makes behavior less predictable as long as the code compiles.
Hint
Look for the option that protects correctness instead of hiding the problem.
Answer and rationale
Correct answer: C. Do not forget to evict indices that fall out of the window before trusting the front element as the answer.
Do not forget to evict indices that fall out of the window before trusting the front element as the answer. This is a common failure mode in real Java code and a frequent interview follow-up.
Track: Java