上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 20 下一页
摘要: class Solution { public: long long f[1010][1010];//f[i][j]表示s前i个字符得到t前j个字符的所有方案 int numDistinct(string s, string t) { f[0][0]=1; int n=s.size(),m=t.si 阅读全文
posted @ 2023-04-15 14:29 穿过雾的阴霾 阅读(13) 评论(0) 推荐(0)
摘要: class Solution { public: int f[25][2010];//体积范围从-1000~1000 int findTargetSumWays(vector<int>& nums, int target) { int n=nums.size(),offset=1000;//价值总和 阅读全文
posted @ 2023-04-14 20:54 穿过雾的阴霾 阅读(17) 评论(0) 推荐(0)
摘要: class Solution { public: bool f[110][110]; bool isInterleave(string s1, string s2, string s3) { int n=s1.size(),m=s2.size(); if(n+m!=s3.size()) return 阅读全文
posted @ 2023-04-14 19:45 穿过雾的阴霾 阅读(14) 评论(0) 推荐(0)
摘要: class Solution { public: int f[25];//f[i]表示i个数可以构成的树的个数 int numTrees(int n) { f[0]=1; for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++)//以j为根节点 f[i]+=f[j- 阅读全文
posted @ 2023-04-13 17:03 穿过雾的阴霾 阅读(14) 评论(0) 推荐(0)
摘要: class Solution { public: TreeNode* pre=NULL; void dfs(TreeNode* root) { if(!root) return; dfs(root->left); root->left=pre; if(pre) pre->right=root; pr 阅读全文
posted @ 2023-04-12 18:45 穿过雾的阴霾 阅读(19) 评论(0) 推荐(0)
摘要: class Solution { public: int f[110]; bool check(char a,char b) { if(a>='1'&&a<='9'&&b>='0'&&b<='9') { int c=a-'0'; c=c*10+(b-'0'); if(c>=1&&c<=26) ret 阅读全文
posted @ 2023-04-12 16:26 穿过雾的阴霾 阅读(13) 评论(0) 推荐(0)
摘要: /* // Definition for a Node. class Node { public: int val; Node* next; Node* random; Node(int _val) { val = _val; next = NULL; random = NULL; } }; */ 阅读全文
posted @ 2023-04-04 15:12 穿过雾的阴霾 阅读(15) 评论(0) 推荐(0)
摘要: 暴力做法 时间复杂度 O (n^2) 遍历一遍,复制 next 指针,新建链表 遍历第二遍,复制 random 指针,查找每一个 random 节点的位置 class Solution { public: ListNode *copyRandomList(ListNode *head) { List 阅读全文
posted @ 2023-04-04 11:21 穿过雾的阴霾 阅读(17) 评论(0) 推荐(0)
摘要: class Solution { public: int method(vector<int> h)//求柱状图中最大的矩形 { int n=h.size(); vector<int> l=vector<int> (n),r=l; stack<int> st; //预处理l,r数组 for(int 阅读全文
posted @ 2023-04-01 11:16 穿过雾的阴霾 阅读(14) 评论(0) 推荐(0)
摘要: class Solution { public: vector<vector<int>> res; vector<int> path; void dfs(TreeNode* root, int sum,int t) { t+=root->val; path.push_back(root->val); 阅读全文
posted @ 2023-04-01 09:55 穿过雾的阴霾 阅读(14) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 20 下一页