Physics, asked by kavin3284, 10 hours ago

Given max. Travel distance and forward and backward route list, return pair of ids of forward and backward routes that optimally utilized the max travel distance.

Answers

Answered by shallom717
0

Answer:

ur mom and joe mama XDXDXD

Answered by presentmoment
0

Travel distance is forward and backward route is 11000.

Explanation:

  • Forward route : [[1,3000] , [3,4000] , [4,10000] , [5,8000]].
  • Backward route : [[1,1000] , [2,3000] , [3,4000]].
  • Max Distance Traveled : 11000.
  • Result must be: [4,1] and [5,2] , as the total traveled distance is 11000 which is less than or equal to max distance.
  • Let's name the "forward" list fwList , the "backward" list bwList. Each element contains a key and a value, in that order.
  • Sort both lists in the ascending order using merge sort or heap sort on the value part of the elements (O(N.In(N)) time complexity.

Similar questions