Google [L3] [Rejected]
Anonymous User
1251

Phone Round
Given,

  1. 1 D co-ordinates of city from origin. for every unit of distance between cities d unit of cost is added to result. d = abs(cord[city1] - cord[city2])
  2. Cost paid to race organizer if race starts from index start and ends in index end is given in array below
    Return cordinates start and end, where the cost obtained is maximum. (i == j) then cost is 0.
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 :(

Comments (4)