Fill rooms with nearest gate distances | Meta Interview Question