Back to problems

Answer multi-round grid and data-structure questions

Algorithm · Bloomberg · Hard

Below are five independent tasks. 1. An array nums is already sorted in non-decreasing order. Given an integer target, return a two-element array [first, last] such that first is the smallest index i where nums[i] == target, and last is the largest index j where nums[j] == target. If target does not appear, return [-1, -1]. The array may be empty. A first/last query on the static array should run in $$O(\log n)$$ time. Follow-up discussions: Suppose new numbers are only…

Checking your access…