Panda Guru LogoPanda
Guru

Salesforce Online Assessment

Round 1

Questions: Problem Statement: There is a dual-core processor with one process queue for each core. There are n processes, where the time to process the ith process is denoted by time(i) (1 ≤ i ≤ n). There is a latch that helps decide which process is processed by which core. Initially, the first core has the latch. Suppose the latch is currently with the cth core, where c is either 1 or 2, and the ith process needs to be assigned. Then one of the following operations must be performed:

The aim of each core is to have a maximum sum of time of processes with them for better performance. So, while assigning the ith process, the core with the latch decides the operation to be performed such that the total sum of time of processes assigned to it is maximized after all the processes are assigned.

Find the sum of the time of processes assigned to the first and second cores if both the cores work optimally. Return an array of two integers, where the first integer is the sum of the time of processes assigned to the first core, and the second integer is the sum of the time of processes assigned to the second core.

Sample I/O:

Candidate's Approach

I attempted to apply both greedy and dynamic programming approaches to solve the problem but was unable to find a solution that worked for all test cases.

Interviewer's Feedback

No feedback provided.