From 3f2b4089fcec09b9398246bc26c4e21e34795ee0 Mon Sep 17 00:00:00 2001 From: DoGoodCoder <141216093+LakshmiSrikumar@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:26:30 +0530 Subject: [PATCH] Create solution_py.py --- solutions/day14/solution_py.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 solutions/day14/solution_py.py diff --git a/solutions/day14/solution_py.py b/solutions/day14/solution_py.py new file mode 100644 index 0000000..398f47c --- /dev/null +++ b/solutions/day14/solution_py.py @@ -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