diff --git a/LeetCode/1402_Reducing_Dishes.py b/LeetCode/1402_Reducing_Dishes.py new file mode 100644 index 0000000..1f2c012 --- /dev/null +++ b/LeetCode/1402_Reducing_Dishes.py @@ -0,0 +1,11 @@ +class Solution: + def maxSatisfaction(self, satisfaction: List[int]) -> int: + + satisfaction.sort(reverse=True) + ans = cur_sum = 0 + for ele in satisfaction: + cur_sum += ele + if cur_sum >= 0: + ans += cur_sum + + return ans; \ No newline at end of file