educative.io

Educative

TreeMap as alternative solution

I think there should be mention of TreeMap as an alternative solution to solve this problem. It is much simpler to implement and has same time/space complexity.


Type your question above this line.

Course: https://www.educative.io/collection/5668639101419520/5671464854355968
Lesson: https://www.educative.io/collection/page/5668639101419520/5671464854355968/5028748841713664

Hi @Matthew_Huynh

Thanks for your valuable feedback.
TreeMap is a Java class but in the lesson, the solution is provided in four different languages. So, heap solution is used as it can be implemented in all four languages.

Thanks!