Uber·Software Engineer·Technical Phone Screen
- You're climbing N floors of a building. You take an elevator for the first x floors (each floor costs t1 time) and stairs for the remaining N-x floors (each stair floor costs e2 energy and takes ceil(c / current_energy) time, with a fixed energy budget E that can't go negative). Find the value of x that minimizes the maximum of the two phase times.
“My first instinct was to just iterate over all x and pick the minimum, which works but the O(N^2) felt gross and I said so out loud which I think was fine.”