024:最长上升子序列

LeetCode 300 https://leetcode.cn/problems/longest-increasing-subsequence/description/ 难度:中等 本题求最长上升子序列(LIS)有两种做法,分别是动态规划和贪心。 ...

六月 29, 2025 · Cassius

018:买卖股票的最佳时机

LeetCode 121 https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/description/ 难度:简单 贪心题目,枚举第 i 天之前价格的最小值,作为买入价格。 时间复杂度:O(n),其中 n 为 prices 的长度。 空间复杂度:O(1)。仅用到若干额外变量。 ...

六月 29, 2025 · Cassius