• 等级
  • 95035 访问
  • 620 原创
  • 11 转发
  • 5850 排名
  • 11 评论
  • 6 获赞

leetcode973+距离最近原点的K个点,sort

https://leetcode.com/problems/k-closest-points-to-origin/classSolution{public:staticboolcmp(pair<int,int>a,pair<int,int>b){returna.second<b.second;...

2019-05-26 19:26:35

leetcode946+栈模拟

https://leetcode.com/problems/validate-stack-sequences/classSolution{public:boolvalidateStackSequences(vector<int>&pushed,vector<int>&popped){stack<int&...

2019-04-28 00:39:40

leetcode945+ 排序之后贪心

https://leetcode.com/problems/minimum-increment-to-make-array-unique/classSolution{public:intminIncrementForUnique(vector<int>&A){intlen=A.size(),cur=0,ans=0;...

2019-04-27 21:15:17

leetcode939+最小矩形面积,hash的set来判断另外两个点存在不存在

https://leetcode.com/problems/minimum-area-rectangle/classSolution{public:intminAreaRect(vector<vector<int>>&points){boolfound=false;intpsize=poin...

2019-04-27 13:15:39

leetcode931,求第一层到最后一层,最小的路径和,Dp

https://leetcode.com/problems/minimum-falling-path-sum/classSolution{public:intminFallingPathSum(vector<vector<int>>&A){intm=A.size(),n=A[0].size();v...

2019-04-27 00:21:13

leetcode926+ 翻转01使得0都在1前面,Dp

https://leetcode.com/problems/flip-string-to-monotone-increasing///dp[i][0]str[0:i-1]最后字符为0时,最少换字符数。//dp[i][1]str[0:i-1]最后字符为1时,最少换字符数。classSolution{public:intminFlipsMonoIncr(...

2019-04-25 23:07:46

leetcode921+最少括号匹配,stack+贪心

https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/classSolution{public:intminAddToMakeValid(stringS){stack<char>s;intres=0;for(auto...

2019-04-21 19:14:27

leetcode852+单峰找到山顶,暴力

https://leetcode.com/problems/peak-index-in-a-mountain-array/classSolution{public:intpeakIndexInMountainArray(vector<int>&A){intn=A.size();for(inti=1;i&lt...

2019-04-18 20:35:16

leetcode896+判断是递增还是递减,两个flage标记

https://leetcode.com/problems/monotonic-array/classSolution{public:boolisMonotonic(vector<int>&A){if(A.size()==1)returntrue;boolincrease=false,decrease...

2019-04-13 11:12:43

tx+algorithm

#include<cstdio>#include<algorithm>#include<cstring>#include<iostream>#include<vector>usingnamespacestd;constintmaxn=3e5+5;intn,k;intmain(){...

2019-04-11 23:37:35

leetcode881+ 乘船问题,双指针

https://leetcode.com/problems/boats-to-save-people/classSolution{public:intnumRescueBoats(vector<int>&people,intlimit){intres=0;sort(people.begin(),peop...

2019-04-11 23:21:56

leetcode872+经典二叉树递归存储叶子节点

https://leetcode.com/problems/leaf-similar-trees/structTreeNode{intval;TreeNode*left;TreeNode*right;TreeNode(intx):val(x),left(NULL),right(NULL){}};classSolution...

2019-04-06 22:01:48

leetcode873+最长的fibonaci,暴力

https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/classSolution(object):deflenLongestFibSubseq(self,A):""":typeA:List[int]:rtype:int...

2019-04-05 17:19:12

leetcode869+判读各位数字重新组合是否为2的幂

https://leetcode.com/problems/reordered-power-of-2/classSolution{public:boolcheck(vector<int>&vis,string&t){vector<int>used(10,0);for(inti=0...

2019-04-05 16:16:51

模拟除法

intmain(){strings;cin>>s;//输入被除数intresult[100001];//结果intdivisor;cin>>divisor;//输入除数intremainder=0;//余数intindex=0;//下标for(inti=0...

2019-03-24 21:13:09

leetcode861+贪心,二进制和统计

https://leetcode.com/problems/score-after-flipping-matrix///贪心classSolution{public:voidFlipRow(vector<vector<int>>&A,introw){for(inti=0;i<A[row].size...

2019-03-24 19:59:43

leetcode856+栈的使用,记得才开始要push记录最终的分数

https://leetcode.com/problems/score-of-parentheses/classSolution{public:intscoreOfParentheses(stringS){stack<int>score;score.push(0);for(autoc:S){...

2019-03-23 22:34:55

leetcode846+set的使用,和循环的表示好

https://leetcode.com/problems/hand-of-straights/classSolution{public:boolisNStraightHand(vector<int>&hand,intW){intn=hand.size();if(n%W!=0)returnfals...

2019-03-23 17:33:57

leetcode841+标准的DFS

classSolution{public:voiddfs(intpos,vector<bool>&flag,vector<vector<int>>&rooms){flag[pos]=true;for(inti=0;i<rooms[pos].size();i...

2019-03-23 15:43:03

leetcode814+移除不包含1的节点,DFS递归

https://leetcode.com/problems/binary-tree-pruning/structTreeNode{intval;TreeNode*left;TreeNode*right;TreeNode(intx):val(x),left(NULL),right(NULL){}};//与其找值全为0的子树,我们...

2019-03-18 00:10:37

小堃哥

关注
奖章
  • 持之以恒
  • 勤写标兵Lv1