摘要: 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 阿破 阅读(88) 评论(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 阿破 阅读(116) 评论(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 阿破 阅读(103) 评论(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 阿破 阅读(168) 评论(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 阿破 阅读(99) 评论(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 阿破 阅读(139) 评论(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 阿破 阅读(76) 评论(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 阿破 阅读(90) 评论(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 阿破 阅读(90) 评论(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 阿破 阅读(78) 评论(0) 推荐(0) 编辑