10 2022 档案
摘要:题目条件: 枚举全排列,是9个数 a,b,c的位数都还不知道 枚举a,b,c的位数,枚举a和b的位数 ,c=9-a-b 判断等式是否成立 // 暴力dfs #include<iostream> #include<cstring> #include<algorithm> using namespace
阅读全文
摘要:#include<iostream> #include<cstring> #include<algorithm> using namespace std; const int N=30; // 多开几个,防止边界越界 int n,m; int way[N]; // 表示方案 // u 代表当前枚举的
阅读全文
摘要:#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; const int N=10; int n; int path[N]; // 0表示没有放数, 1-n表示放的
阅读全文
摘要:题解1: // 指数型枚举 // 题意是给出得数字都有两种选择,选或者不选 // 画出递归树理解题意 #include<iostream> #include<cstring> #include<algorithm> using namespace std; const int N=16; int n
阅读全文
摘要:994. 腐烂的橘子 来自 <https://leetcode.cn/problems/rotting-oranges/> class Solution { public: // bfs int orangesRotting(vector<vector<int>>& grid) { int dx[4
阅读全文
摘要: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
阅读全文
摘要:206. 反转链表 来自 <https://leetcode.cn/problems/reverse-linked-list/> /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *n
阅读全文
摘要:21. 合并两个有序链表 来自 <https://leetcode.cn/problems/merge-two-sorted-lists/> /** * Definition for singly-linked list. * struct ListNode { * int val; * ListN
阅读全文
摘要:785. 快速排序 来自 <https://www.acwing.com/problem/content/submission/code_detail/18083617/> #include<iostream> using namespace std; const int N=100010; int
阅读全文
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) :
阅读全文
摘要: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
阅读全文
摘要:/* // Definition for a Node. class Node { public: int val; Node* left; Node* right; Node* next; Node() : val(0), left(NULL), right(NULL), next(NULL) {
阅读全文
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig
阅读全文
摘要:567. 字符串的排列 来自 <https://leetcode.cn/problems/permutation-in-string/?envType=study-plan&id=suan-fa-ru-men&plan=algorithms&plan_progress=sc0sqw2> class
阅读全文
摘要: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>
阅读全文
摘要: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
阅读全文