Free round · easy · about 15 min

Owl Watch Rotation

Solve it here, in your browser. No account needed.

The Thornwood owl sanctuary logs how many owl sightings its motion sensors record in each hour of the night. A volunteer signs up for one continuous watch of exactly watchHours hours and wants the shift that will see the most activity.

Given the hourly sighting counts in chronological order, return the largest total number of sightings any single continuous watch of exactly watchHours hours could cover.

If the night is shorter than one full watch, no valid shift exists and the answer is 0.

Worked example

With counts [3, 1, 4, 1, 5, 9, 2] and a 3-hour watch, the candidate shifts are 3+1+4 = 8, 1+4+1 = 6, 4+1+5 = 10, 1+5+9 = 15, and 5+9+2 = 16. The best is the final one, so the answer is 16.

Visible tests

Write your solution, then press Run. Your code runs in your browser; nothing is sent to us.

The full round adds

  • Hidden edge-case and speed tests
  • Mocky, the AI assistant, with a two-prompt budget
  • A score, a debrief and your progress over time
  • Six more languages, from Java to Go