Skip to content

Commit 87a3e8a

Browse files
committed
chore: sync automated leetcode submissions with Runtime - 800 ms (83.78%), Memory - 44.4 MB (57.43%)
1 parent 8e3628a commit 87a3e8a

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • 3351-maximize-happiness-of-selected-children
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def maximumHappinessSum(self, happiness: List[int], k: int) -> int:
3+
happiness.sort(reverse=True)
4+
5+
total_happiness = 0
6+
for i in range(k):
7+
current_val = happiness[i] - i
8+
if current_val <= 0:
9+
break
10+
11+
total_happiness += current_val
12+
13+
return total_happiness

0 commit comments

Comments
 (0)