Question
Simulate a page cache using the CLOCK (second-chance) eviction policy. The cache holds at most `capacity` pages arranged in a circular buffer with a clock hand that starts at slot 0. Each page has a reference bit. Process a list of page-id accesses. On access: if the page is resident it is a HIT and its reference bit is set to 1. On a miss, if there is a free slot the page is loaded there (ref bit 1) and the hand is unchanged; if the cache is full, advance the hand, repeatedly clearing ref bits of pages with bit 1 (giving second chances) until a page with bit 0 is found — evict it, load the new page in its slot with ref bit 1, and leave the hand pointing one past that slot. Return the total number of hits. capacity >= 1; <= 10^5 accesses.
clock_cache_hits(capacity: int, accesses: list[int]) → int[2,[1,2,1,3,2]]out2State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.