A lot of problems on LeetCode require the use of a Priority Queue. Without it, even though your implementation works, it will not be efficient enough and the submission might fail with the dreaded "Time Limit Exceeded", passing only 980 out of 1000 tests.
Solving questions without a Priority Queue