Hey all just got back from a java interview, didn't go very well unfortunately
. I took a picture of the question in the hopes of understanding how to solve it but I still cant wrap my head around it, can anyone provide the solutions.
You are given an array on integers n length n for a driver. The integer at index i symbolizes the time allocated to her or his i'th task in minutes. The optimal time for a break s between two tasks i and i+1, when the sum of all tasks from 0 to i equals the sum i+1 to n .
Write a method that returns index i where the condition above is met. If there is no such index the driver is not awarded a break and the method returns null.
Input [1, 4, 1, 3, 1] -> Output 1
Input [1, 4, 1, 3] -> Output null
Can you find a solution that efficiently handles 3, 4, ..., m breaks ?
Thanks in advance!