Round 1
Questions:
-
Given n servers with their capacity, we need to schedule k batches.
- Input:
- n (number of servers)
- Capacity array of length n
- K (batches)
- numServers array of length k where numServers[i] = number of servers to be included in i-th batch
- Constraints:
- Summation of numServers[i] == n
- n <= 1e6
- K <= n
- Output:
- For each batch calculate the difference between maximum and minimum server capacity, sum it over for all k batches and return it.
- Sample:
- n=4
- capacity: [1,2,3,4]
- k=1
- numServers:[4]
- output: 4-1=3
- n=4
- capacity: [1,2,3,4]
- k=4
- numServers:[1, 1, 1, 1]
- output: 0
- n=4
- capacity: [1,2,3,4]
- k=2
- numServers:[2, 2]
- output: (4-1) + (3-2) = 4
- n=4
- Input:
-
There are two cores and N processes with a profit array of length N given.
- Schedule these N processes on these two cores such that total profit for each core is maximized.
- Scheduling rule:
- There's a latch initially with core 1. The core with latch can do either of two operations:
- Schedule process on itself and pass the latch to the other core.
- Schedule process on the other core and keep the latch.
- There's a latch initially with core 1. The core with latch can do either of two operations:
Candidate's Approach
I was able to solve the first problem using greedy logic, but could not quite get the memoization code to work for the second problem for all test cases.
Interviewer's Feedback
No feedback provided.