Dsa
Prefix Sum
Easy
The Wildlife Camera
A wildlife camera records the number of animals spotted every hour for N hours. Researchers want to know the maximum number of animals spotted in any contiguous window of K hours.
Input Format:
- Line 1: Two integers N and K.
- Line 2: N integers representing hourly sightings.
Output Format:
- The maximum sum of any K-hour window.
Example:
Input:
5 2
1 5 2 10 3
Output:
13
Key concepts
prefix_sumsliding_window
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now