Code RoomWake lock never released
HardPrep Room Coding #4213

Wake lock never released

Vibe & agenticAlgorithms & data structuresSenior–Staff~18 min

An AI wrote this Android background sync to keep data fresh, taking a wake lock 'so it doesn't get killed'. It works, but users complain the app destroys their battery overnight and Play Console flags excessive wakeups. What's wrong and how would you fix it?

Implement
estimate_cpu_awake_seconds(window_minutes: int, interval_minutes: int, sync_seconds: int, lock_timeout_seconds: int) → int
Examples
in[480,1,5,0]out28800
in[480,1,5,30]out2400
in[480,15,5,30]out160
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 18 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.