Jim and the Orders

  • + 0 comments

    Easy Approach by adding the values and assigning the index of each order to retrive based on their priority and then sorting the result based on the 2nd element in the summed array by using lambda function and then iterating through that sorted array in order to retrieve the order priority list and then returning it in type of res. Hope you understand!! Happy Coding!!

    def jimOrders(l): sum_l = sorted([[sum(j),i+1] for i,j in enumerate(l)], key = lambda x: x[0]) res = [ i[1] for i in sum_l] return res `