My LeetCode grinding. Trying to do a problem a day.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

problem.txt 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.
  2. Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. time[i]*satisfaction[i]
  3. Return the maximum sum of Like-time coefficient that the chef can obtain after dishes preparation.
  4. Dishes can be prepared in any order and the chef can discard some dishes to get this maximum value.
  5. Example 1:
  6. Input: satisfaction = [-1,-8,0,5,-9]
  7. Output: 14
  8. Explanation: After Removing the second and last dish, the maximum total Like-time coefficient will be equal to (-1*1 + 0*2 + 5*3 = 14). Each dish is prepared in one unit of time.
  9. Example 2:
  10. Input: satisfaction = [4,3,2]
  11. Output: 20
  12. Explanation: Dishes can be prepared in any order, (2*1 + 3*2 + 4*3 = 20)
  13. Example 3:
  14. Input: satisfaction = [-1,-4,-5]
  15. Output: 0
  16. Explanation: People don't like the dishes. No dish is prepared.
  17. Example 4:
  18. Input: satisfaction = [-2,5,-1,0,3,-3]
  19. Output: 35
  20. Constraints:
  21. n == satisfaction.length
  22. 1 <= n <= 500
  23. -10^3 <= satisfaction[i] <= 10^3