随笔分类 -  算法

摘要:自己没想到最优解,题解的思路记录一下吧 题目:【https://leetcode.cn/problems/longest-consecutive-sequence/description/?envType=study-plan-v2&envId=top-interview-150】 1 class 阅读全文
posted @ 2025-04-27 10:33 J&YANG 阅读(7) 评论(0) 推荐(0)
摘要:这个题目上栽跟头了,逆向思路没想到,记录一下 题目:【https://leetcode.cn/problems/surrounded-regions/description/?envType=study-plan-v2&envId=top-interview-150】 1 class Solutio 阅读全文
posted @ 2025-04-14 17:01 J&YANG 阅读(6) 评论(0) 推荐(0)
摘要:记录一下自己的思路,典型的dfs题目 题目:【https://leetcode.cn/problems/number-of-islands/description/?envType=study-plan-v2&envId=top-interview-150】 1 class Solution { 2 阅读全文
posted @ 2025-04-14 11:26 J&YANG 阅读(17) 评论(0) 推荐(0)
摘要:记录一下自己思路,核心问题在于两种情况,一个是从0到n - 1进行DP,第二条路径是1到n进行DP,然后比较大小,不要试图检查路径中是否包含第0家,因为可以空一个,也可以空两个,根本没法追踪。。。 题目:【https://leetcode.cn/problems/house-robber-ii/de 阅读全文
posted @ 2025-04-11 15:21 J&YANG 阅读(13) 评论(0) 推荐(0)
摘要:记录一下思路 题目:【https://leetcode.cn/problems/house-robber/?envType=study-plan-v2&envId=top-interview-150】 1 class Solution { 2 public: 3 int rob(vector<int 阅读全文
posted @ 2025-04-11 14:05 J&YANG 阅读(13) 评论(0) 推荐(0)
摘要:自己的思路记录一下,不难,但是几个判断条件听绕,另外数组的初始值 题目:【https://leetcode.cn/problems/coin-change/description/?envType=study-plan-v2&envId=top-interview-150】 c++版本 1 clas 阅读全文
posted @ 2025-04-11 13:07 J&YANG 阅读(4) 评论(0) 推荐(0)
摘要:记录一下自己当时的思路,矩阵快速幂暂时没有尝试 题目:【https://leetcode.cn/problems/climbing-stairs/?envType=study-plan-v2&envId=top-interview-150】 初版思路 1 static int cache[45]; 阅读全文
posted @ 2025-04-11 09:51 J&YANG 阅读(5) 评论(0) 推荐(0)
摘要:记录一下自己的思路,做完题目后,发现跟答案一模一样。。。记录了个寂寞 题目:【https://leetcode.cn/problems/convert-sorted-array-to-binary-search-tree/description/?envType=study-plan-v2&envI 阅读全文
posted @ 2025-04-10 15:11 J&YANG 阅读(8) 评论(0) 推荐(0)
摘要:将自己的思路记录一下 题目:【https://leetcode.cn/problems/reverse-linked-list-ii/description/?envType=study-plan-v2&envId=top-interview-150】 1 /** 2 * Definition fo 阅读全文
posted @ 2025-02-07 14:16 J&YANG 阅读(10) 评论(0) 推荐(0)
摘要:#include <iostream> #include <list> using namespace std; int main() { // 对象总数 int numObj = 0; // 依赖关系数 int numDep = 0; cin >> numObj >> numDep; // 储存依 阅读全文
posted @ 2021-06-02 14:19 J&YANG 阅读(146) 评论(0) 推荐(0)