Sort 296 Discussions, By:
Please Login in order to post a comment
This problem is mistakenly placed into Queue subdomain, while it must be placed under 'Heap'.
I wasted some time trying to understand how it's possible to effectively use a queue (and not min-heap that immediately comes to mind).
This crummy trend in Hackerrank problem description is becoming really annoying. Please provide more test cases and/or explain better the problem.
Here the "-1" case is really ambiquious and I had to take shots on what the author had in mind...
I used PriorityQueue with java 8 and failed case 22
then I moved to java 7 it passed !
Getting testcase 18 as wrong . Can't figure out what edge case I'm missing
solution for python 3 using heapq
from heapq import heappop,heappush,heapify
firstLine = [int(x) for x in input().split()]
cookies = [int(x) for x in input().split()]
cookieCount = int(firstLine)
minSweetness = int(firstLine)
fC = 0
while cookies < minSweetness:
c1 = heappop(cookies)
c2 = heappop(cookies)