i tried doing the below code but it didnt work. Problem is in making min heap of type ListNode *.
Q. 23…leetcode…merge k sorted lists (https://leetcode.com/problems/merge-k-sorted-lists/)
i tried doing the below code but it didnt work. Problem is in making min heap of type ListNode *.
Q. 23…leetcode…merge k sorted lists (https://leetcode.com/problems/merge-k-sorted-lists/)
You want the idea or correct code?
First of all you can’t use greater<…>() here 2m ✓
as there can not be anything inbuilt for your own declared structure 1m ✓
second, the random output is because you are passing pointers to the greater function, which treats it as of type unisgned int and returns the one with smaller pointer address just now ✓
in short it is completely wrong just now ✓
and you need to tell the compiler how to compare two objects of the type ListNode* just now ✓
else how’ll it know