How did you come up with this approach many people are using treemap/priority queue/min heap for it ,how to decide the good one? I personally loved this solution since it is straight forward! Thanks
Well I realized that I need to know the min value available and can get the rest from there so yeah either min heap or just use hashmap and array since my values never change. Heap better for when your values change instead of static.