随笔分类 -  leetcode算法题总结

2022年10月13日23点22分,归纳总结过程也当作复习代码思路
摘要:994. 腐烂的橘子 来自 <https://leetcode.cn/problems/rotting-oranges/> class Solution { public: // bfs int orangesRotting(vector<vector<int>>& grid) { int dx[4 阅读全文
posted @ 2022-10-19 09:35 努力、奋斗啊 阅读(25) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: // dfs vector<vector<int>> res; vector<int> path; // 只能是全局变量 bool flag[100]; int n=0; void dfs(int u,vector<int>& nums){ if(u 阅读全文
posted @ 2022-10-18 08:55 努力、奋斗啊 阅读(16) 评论(0) 推荐(0) 编辑
摘要:206. 反转链表 来自 <https://leetcode.cn/problems/reverse-linked-list/> /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *n 阅读全文
posted @ 2022-10-16 18:59 努力、奋斗啊 阅读(13) 评论(0) 推荐(0) 编辑
摘要:21. 合并两个有序链表 来自 <https://leetcode.cn/problems/merge-two-sorted-lists/> /** * Definition for singly-linked list. * struct ListNode { * int val; * ListN 阅读全文
posted @ 2022-10-16 18:36 努力、奋斗啊 阅读(19) 评论(0) 推荐(0) 编辑
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : 阅读全文
posted @ 2022-10-15 13:56 努力、奋斗啊 阅读(14) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: // 除k取余法求二进制 (暴力) vector<int> countBits(int n) { vector<int> ans; for(int i=0;i<=n;i++){ int t=i; int count=0; while(t!=0){ i 阅读全文
posted @ 2022-10-15 13:55 努力、奋斗啊 阅读(16) 评论(0) 推荐(0) 编辑
摘要:/* // Definition for a Node. class Node { public: int val; Node* left; Node* right; Node* next; Node() : val(0), left(NULL), right(NULL), next(NULL) { 阅读全文
posted @ 2022-10-15 13:53 努力、奋斗啊 阅读(10) 评论(0) 推荐(0) 编辑
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig 阅读全文
posted @ 2022-10-15 13:52 努力、奋斗啊 阅读(22) 评论(0) 推荐(0) 编辑
摘要:567. 字符串的排列 来自 <https://leetcode.cn/problems/permutation-in-string/?envType=study-plan&id=suan-fa-ru-men&plan=algorithms&plan_progress=sc0sqw2> class 阅读全文
posted @ 2022-10-14 00:08 努力、奋斗啊 阅读(22) 评论(0) 推荐(0) 编辑
摘要:733. 图像渲染 来自 <https://leetcode.cn/problems/flood-fill/> class Solution { public: // bfs int dx[4]={-1,0,1,0}; int dy[4]={0,1,0,-1}; vector<vector<int> 阅读全文
posted @ 2022-10-14 00:04 努力、奋斗啊 阅读(34) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: // bfs适合距离为1的情形; int n,m; int maxAreaOfIsland(vector<vector<int>>& grid) { int maxArea =0; n=grid.size(); m=grid[0].size(); v 阅读全文
posted @ 2022-10-13 23:45 努力、奋斗啊 阅读(18) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示