From d5596d40fe37cadb2fa4c76dae756b25527ccdf5 Mon Sep 17 00:00:00 2001 From: nainys <30886059+nainys@users.noreply.github.com> Date: Sat, 10 Oct 2020 17:00:09 +0530 Subject: [PATCH] add: solution to reducing dishes --- LeetCode/1402_Reducing_Dishes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 LeetCode/1402_Reducing_Dishes.py 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