【Leetcode】373. Find K Pairs with Smallest Sums

【Leetcode】373. Find K Pairs with Smallest Sums_第1张图片

1 用heap做:将(和,nums1坐标,nums2坐标)压入栈中


【Leetcode】373. Find K Pairs with Smallest Sums_第2张图片

heapq is a binary heap, with O(log n) push and O(log n) pop


【Leetcode】373. Find K Pairs with Smallest Sums_第3张图片

你可能感兴趣的:(【Leetcode】373. Find K Pairs with Smallest Sums)