Find K Pairs with Smallest Sums - LeetCode 373 - Python

preview_player
Показать описание
Solution, explanation, and complexity analysis for LeetCode 373, the problem of the day for June 27th, in Python.
Рекомендации по теме
Комментарии
Автор

great solution, and I learned that python heappush sorts array entries lexicographically

klnlkjoinoin
Автор

Hi, just discovered your channel. Just wanted to say that the way you approached the problem resonates with me a lot. I wasn’t able to come up with using a heap though because I was too deep believing it was a 2-pointer problem. Keep up the good work!

Gzzzzzz
Автор

Small update to the complexities, the time should be O(min( k* log(k), m*n*log(m*n))) instead of what I have because the maximum combinations are m*n not m+n. However, since k can only be 10^4 this number still can't get too big for either space or time.

Alpha-Code