Skip to content

Commit

Permalink
Merge pull request #76 from LakshmiSrikumar/patch-1
Browse files Browse the repository at this point in the history
Create solution_py.py
  • Loading branch information
arya2004 authored Oct 14, 2024
2 parents b7551ba + 3f2b408 commit f810623
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions solutions/day14/solution_py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution:
def maxKelements(self, nums: List[int], k: int) -> int:
heapify(pq:=[-x for x in nums])
score=0
for i in range(k):
x=-heappop(pq)
score+=x
if x==1:
score+=k-1-i
break
heappush(pq, -((x+2)//3))
return score

0 comments on commit f810623

Please sign in to comment.