We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# using heap sortimportheapqdefcookies(k,nums):# Write your code hereheapq.heapify(nums)count=0while(nums):x=heapq.heappop(nums)ifx>=k:returncountifnotnums:return-1y=heapq.heappop(nums)#formulan=x+(2*y)heapq.heappush(nums,n)count+=1# loop exits without giving countreturn-1
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Jesse and Cookies
You are viewing a single comment's thread. Return to all comments →