Algorithm · Uber · Medium
Part 1: Highest Safe Floor You are handed a monotonic boolean array safe, where safe[i] reports whether floor i + 1 is safe for the elevator to serve. Somewhere in the array there is a threshold T: every floor from 1 through T is True, and every floor from T + 1 through n is False. Report T, the largest safe floor number. When no floor at all is safe, the answer is 0, and the same holds for an empty array. Your solution must locate T with binary search rather than a linear…
Checking your access…