Selecting A combination of minimum cost

前端 未结 5 1634
天命终不由人
天命终不由人 2020-12-10 09:07

I have data of different items in a different restaurants

    Rest    Item     Price
    ----------------------
    ABC     dosa      14
    ABC     idly             


        
5条回答
  •  醉酒成梦
    2020-12-10 09:58

    1. Calculate the possible price combinations: Iterate through the map and parse the strings. Store each price combination.

    2. Filter out the more expensive prices.

    3. Compare the remaining prices at each restaurant, and return the restaurant with the cheapest price.

    You could also do some checks to minimise iterations, e.g:

    • If idly is > than idly+umpa, don't calculate the any combinations involving idly.

提交回复
热议问题