Can every car park with preferred spots and forward-only overflow

0
Remix

A one-way street has n spots numbered 0 to n - 1. Cars arrive in order; car i wants spot preferences[i], takes it if free, and otherwise drives forward to the next free spot. A car that passes the last spot fails to park. Decide whether every car finds a spot, and do better than simulating each car's walk.

MercorCodingLast asked Sep 2026
No answer yet. Write the first one; the best answer gets endorsed.