The OA had two coding questions in total. Overall difficulty was Easy to Medium, mainly testing Array Simulation and Greedy.
The specific questions:
Dropped Requests (Array Simulation): you are given an integer array. A positive integer means adding that many server threads, and -1 means a request comes in. Each request uses up one thread, and if there is no thread available the request is dropped. Return the total number of dropped requests. Just walk through the array and keep track of the current number of threads, O(n).
Maximum XOR (Greedy): you are given a binary string x, bits, and maxSet. You need to construct a binary string y that has at most maxSet ones and maximizes x XOR y. Go through the bits from the highest to the lowest, and prefer setting y to 1 at the positions where x is 0. O(n).
Discussion
Loading comments…