Questions one and two were pretty easy, I don't really remember them.
Three:
The prompt was long.
You're given an int array representing the capacities of warehouses 0 through n - 1, plus an array of events. Events are either "PACKAGE" (process one package) or "CLOSURE X" (close warehouse N). Packages start being processed at warehouse 0, and once a warehouse hits capacity, the next warehouse that isn't closed takes over. Once warehouse N-1 fills up, processing wraps back around to warehouse 0 — capacities reset, but closures don't.
In the end, return the id of the warehouse that processed the most packages. If there's a tie, return the largest id.
Four:
The prompt was long too. You're given two int arrays A and B, and a series of operations. There are two kinds of operations:
- Sum query — given a target sum, count how many pairs (one element from A, one from B) add up to it.
- Update — replace some element of array B with a new value.
The return value is an array containing the result of each operation 2.
For example:
A: 1, 3
B: 2, 4
Operations:
1, 5
2, 0, 3
1, 4
The answer is [2, 1] — there were originally 2 pairs summing to 5, and after the update there was only 1 pair summing to 4.
There was a lot of test data, so you needed to optimize the time complexity, but I didn't get to see what the input that timed out looked like.
Discussion
Loading comments…