20260114

20260113

20260112

grep -E '^- \[.*\]\(https://github.com/.*/pull/[0-9]+\)' leetcode.md | wc -l

20260111

I was thinking about just chilling today, but I ended up doing many household chores and studying hard.

20260110

20260109

20260108

import heapq


class Solution:
    def kSmallestPairs(
        self, nums1: list[int], nums2: list[int], k: int
    ) -> list[list[int]]:
        sum_and_pairs: list[tuple[int, tuple[int, int]]] = [
            (nums1[0] + nums2[0], (0, 0))
        ]
        checked_pairs: set[tuple[int, int]] = set()
        smallest_pairs: list[list[int]] = []
        while sum_and_pairs and len(smallest_pairs) < k:
            index1, index2 = heapq.heappop(sum_and_pairs)[1]
            if (index1, index2) in checked_pairs:
                continue

            smallest_pairs.append([nums1[index1], nums2[index2]])
            checked_pairs.add((index1, index2))

            if index1 + 1 < len(nums1):
                heapq.heappush(
                    sum_and_pairs,
                    (nums1[index1 + 1] + nums2[index2], (index1 + 1, index2)),
                )
            if index2 + 1 < len(nums2):
                heapq.heappush(
                    sum_and_pairs,
                    (nums1[index1] + nums2[index2 + 1], (index1, index2 + 1)),
                )

        return smallest_pairs
import heapq


class Solution:
    def kSmallestPairs(
        self, nums1: list[int], nums2: list[int], k: int
    ) -> list[list[int]]:
        sum_and_pairs = []
        for i in range(len(nums1)):
            heapq.heappush(sum_and_pairs, (nums1[i] + nums2[0], (i, 0)))

        smallest_pairs = []
        while sum_and_pairs and len(smallest_pairs) < k:
            index1, index2 = heapq.heappop(sum_and_pairs)[1]
            smallest_pairs.append([nums1[index1], nums2[index2]])

            if index2 + 1 < len(nums2):
                heapq.heappush(
                    sum_and_pairs,
                    (nums1[index1] + nums2[index2 + 1], (index1, index2 + 1)),
                )

        return smallest_pairs

20260107

20260106

20260105

20260104

20260103

#include <algorithm>
#include <vector>

class Solution {
public:
    int maxProfit(std::vector<int>& prices) {
        int profit = 0;
        for (int i = 1; i < prices.size(); ++i) {
            profit += std::max(0, prices[i] - prices[i - 1]);
        }
        return profit;
    }
};

20260102

20260101


TODO:


index 202512 202602