Phone Round
Given,
cord[] : [ 0, 3, 7, 11 ]
startCost[]: [12, 5, 4 , 7]
endCost[]: [1, 4, 3, 4]
Actual cost is computed as, startCost[startIndex] + endCost[endIndex] + abs(cord[endIndex] - cord[startIndex])
start at index 0 -> cost is 12
end at index 3 -> cost is 4
distance should be also accompanied to total cost which is (11 - 0) = 11
ans: 27
I could only come up with O(n^2) apprach :(