Jim and the Orders

  • + 0 comments

    C#

    public static List<int> jimOrders(List<List<int>> orders)
    {
        var res= new List<int>();
        Dictionary<int,int> map = new Dictionary<int,int>();
    
        for (int i = 0; i < orders.Count;i++)
        {
            map[i+1] = orders[i][0] + orders[i][1];
    
        }
    
        var mapSort = map.OrderBy(x => x.Value).ToList();
        foreach (var item in mapSort)
        {
            res.Add(item.Key);
        }
        return res;
    }