In a problem from Hackerrank, this question baffled me. I believe it should work fine but my output does not reflect on the expected output... Where have I gone wrong? (also I can only edit the code before the Solution class)
Stephan van Hulst wrote:Do you know how the enhanced for-loop works? You might want to look up the documentation of the applicable method of the PriorityQueue class.
They go through every element one by one each repeat? I've read somewhere that iterators/enhanced for loops don't respect any particular orders but when using for loops over ArrayLists, they check each element in order? Sorry about bothering