← Questions
Can every car park with preferred spots and forward-only overflow
0
I was asked this
No reports yet. Sign in to say where you were asked it.
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.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
