07 2020 档案

摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), r 阅读全文
posted @ 2020-07-30 20:56 阿破 阅读(128) 评论(0) 推荐(0)
摘要:class Solution { int f[505][505]; public: int maxDotProduct(vector<int>& nums1, vector<int>& nums2) { int m=nums1.size(),n=nums2.size(); int ans=-1e9; 阅读全文
posted @ 2020-07-30 12:45 阿破 阅读(121) 评论(0) 推荐(0)
摘要:class Solution { public: string removeKdigits(string num, int k) { int n=num.size(); string ans; int p=0; int c=n-k;//挑c个 for(int i=0;i<c;i++){ string 阅读全文
posted @ 2020-07-29 21:43 阿破 阅读(95) 评论(0) 推荐(0)
摘要:class Solution { public: vector<vector<int>> groupThePeople(vector<int>& gr) { vector<vector<int>>ans,ret; ans.resize(gr.size()+1); ans[gr[0]].push_ba 阅读全文
posted @ 2020-07-29 18:42 阿破 阅读(98) 评论(0) 推荐(0)
摘要:class Solution { public: int minDistance(string word1, string word2) { int n1=word1.size(),n2=word2.size(); int dp[n1+1][n2+1]; for(int i=0;i<=n1;i++) 阅读全文
posted @ 2020-07-28 16:29 阿破 阅读(96) 评论(0) 推荐(0)
摘要:class Solution { int cnt=1; queue<int> q; string ans; map<string,char>m; public: typedef struct in { int son[128]; int fail; string strInfo; }in; void 阅读全文
posted @ 2020-07-27 15:23 阿破 阅读(127) 评论(0) 推荐(0)
摘要:int find(int i){ return f[i]==i?i:f[i]=find(f[i]); } int Union(int nd1,int nd2){ int a=find(nd1); int b=find(nd2); if(a==b) return 0; if(rank[a]<=rank 阅读全文
posted @ 2020-07-27 11:07 阿破 阅读(115) 评论(0) 推荐(0)
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig 阅读全文
posted @ 2020-07-26 15:03 阿破 阅读(184) 评论(0) 推荐(0)
摘要:class Solution { int qx[10005],qy[10005],d[105][105],he,ta,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1}; public: int maxDistance(vector<vector<int>>& grid) { int 阅读全文
posted @ 2020-07-22 18:47 阿破 阅读(110) 评论(0) 推荐(0)
摘要:class Solution { public: void dfs(vector<vector<int>>& A,int i,int j){ if(i<0||i>=A.size()||j<0||j>=A[0].size())return; if(A[i][j]==1) A[i][j]=2; else 阅读全文
posted @ 2020-07-21 19:10 阿破 阅读(149) 评论(0) 推荐(0)
摘要:class Solution { int p[200005],ne[200005],h[200005],f[200005],s[100005][26],m=0; string t; vector<int> ans; public: void dfs(int x){ s[x][t[x]-'a']=1; 阅读全文
posted @ 2020-07-20 21:47 阿破 阅读(82) 评论(0) 推荐(0)
摘要:class Solution { int ans=0; public: int fun(int numBottles,int n,int numExchange){ ans+=numBottles; //置空 n+=numBottles; numBottles=0; //替换 numBottles= 阅读全文
posted @ 2020-07-20 10:50 阿破 阅读(101) 评论(0) 推荐(0)
摘要:class Solution { public: bool a[100005][26]; vector<bool> ans; vector<bool> canMakePaliQueries(string s, vector<vector<int>>& queries) { int n=s.size( 阅读全文
posted @ 2020-07-16 20:30 阿破 阅读(101) 评论(0) 推荐(0)
摘要:因子能分解为2,3,5的为丑数 class Solution { public: bool isUgly(int num) { if(num<=0) return 0; if(num<=5) return 1; return isUgly(num%2==0?num/2:0)||isUgly(num% 阅读全文
posted @ 2020-07-15 14:13 阿破 阅读(86) 评论(0) 推荐(0)
摘要:class Solution { vector<vector<pair<int,double> > >v; public: double maxProbability(int n, vector<vector<int>>& edges, vector<double>& succProb, int s 阅读全文
posted @ 2020-07-12 21:15 阿破 阅读(194) 评论(0) 推荐(0)
摘要:class Solution { public: int findTheLongestSubstring(string s) { /*需要找到状态为0的子序列[i,j],[i,j]=[0,j]-[0,i](两者状态相同时的差) */ int state=0,ans=0; vector<int> p( 阅读全文
posted @ 2020-07-11 10:15 阿破 阅读(112) 评论(0) 推荐(0)
摘要:class Solution { public: TreeNode* dfs(TreeNode *&root,int target){ if(!root) return root; dfs(root->left,target); dfs(root->right,target); if(root->v 阅读全文
posted @ 2020-07-10 15:23 阿破 阅读(110) 评论(0) 推荐(0)
摘要:class Solution { public: bool canFinish(int numCourses, vector<vector<int>>& prerequisites) { int n=0; queue<int> s; vector<int> h[numCourses],indeg(n 阅读全文
posted @ 2020-07-10 13:27 阿破 阅读(106) 评论(0) 推荐(0)
摘要:class Solution { public: vector<int> gardenNoAdj(int N, vector<vector<int>>& paths) { vector<int> G[N]; for (int i=0; i<paths.size(); i++){//建立邻接表 G[p 阅读全文
posted @ 2020-07-08 18:45 阿破 阅读(142) 评论(0) 推荐(0)
摘要:class Solution { public: ListNode* swapPairs(ListNode* head) { ListNode* res=NULL; if(!head) return res; ListNode* front=head,*back=head->next,*n,*p=n 阅读全文
posted @ 2020-07-07 10:53 阿破 阅读(174) 评论(0) 推荐(0)
摘要:class Solution { public: ListNode* mergeKLists(vector<ListNode*>& lists) { ListNode* head=new ListNode(0),*minval=NULL,*p=head; int n=lists.size(),m=0 阅读全文
posted @ 2020-07-07 10:13 阿破 阅读(121) 评论(0) 推荐(0)