Hi, Folks! Today I want to share my experience in LeetCode problem-solving. I am a beginner in data structures and algorithms, and currently, I am focusing on Python. I solved three questions from the linked list concept on LeetCode: Merge k Sorted Lists, Reverse Linked List, and Add Two Numbers.
For the problem Merge k Sorted Lists, there are many approaches you can choose. But, choosing the most efficient one comes with practice. As a beginner, I started with this approach: I created a new list, merged all the given lists into the newly created list, and then sorted it.
After completing the coding part, I wanted to know if there were any other approaches. So, I went through some resources and discovered that there is an even more efficient way using a min-heap. I found this approach to be more logical compared to mine, and this realization comes only with practice. If we can think of the most efficient logic in our first approach, it indicates that we are experts in programming.
Top comments (0)