Shortest Path for delivery time, online pharmacy company

Input: [ (RouteId:Int, CourierId:Int, DeliveryTime:Int) ]
Example input:
[
[1, 1, 20],
[1, 1, 10],
[2, 2, 30],
[2, 2, 6],
[3, 1, 50],
[3, 2, 30],
[4, 2, 30],
[4, 2, 5]
]

  1. find the different RouteId, with shortest delivery time.
    output: [[1, 10], [2, 6], [3, 30],[4, 5]]

  2. find the same RouteId, same CourierId, with average delivery time
    output: [[1, 1, 15], [2, 2, 18], [3, 1, 50],[3, 2, 30], [4, 2, 17.5]]

    How to write code for this question???

Comments (4)