Back to problems

Seat Assignment / Exam Room

Algorithm · Uber · Hard

Requirements Create a class that assigns people to one of n seats numbered from 0 through n-1. Every invocation of assign() must place the next person where their distance to the closest occupied seat is as large as possible, then return that position. The initial assignment must use seat 0. If multiple positions achieve the same best distance, either choice is valid; ask the interviewer which tie-breaking behavior they expect. Once assigned, a seat remains occupied…

Checking your access…