2022年7月3日

LeetCode673 最长递增子序列的个数

摘要: LeetCode673 最长递增子序列的个数 贪心 + 前缀和 + 二分查找 $q[i][]$ 数组表示所有能成为长度为 $i$ 的最长上升子序列的末尾元素的值 $cnt[i][j]$ 记录以 $q[i][j]$ 为结尾的最长上升子序列的个数 参考 class Solution: def findN 阅读全文

posted @ 2022-07-03 15:54 solvit 阅读(27) 评论(0) 推荐(0)

LeetCode560 和为 K 的子数组

摘要: LeetCode560 和为 K 的子数组 前缀和 + 哈希 class Solution: def subarraySum(self, nums: List[int], k: int) -> int: pre_count, pre, ans = {}, 0, 0 pre_count[0] = 1 阅读全文

posted @ 2022-07-03 13:44 solvit 阅读(25) 评论(0) 推荐(0)

导航