上一页 1 2 3 4 5 6 7 8 9 ··· 19 下一页

2016年4月21日

扑克牌顺子

摘要: 1 class Solution { 2 public: 3 4 bool IsContinuous( vector numbers ) { 5 if(numbers.size()==0) 6 return false; 7 sort(numbers.begin(),numbers.end()); 8 ... 阅读全文

posted @ 2016-04-21 17:46 RenewDo 阅读(115) 评论(0) 推荐(0) 编辑

2016年4月20日

[编程题]树上最长单色路径

摘要: 对于一棵由黑白点组成的二叉树,我们需要找到其中最长的单色简单路径,其中简单路径的定义是从树上的某点开始沿树边走不重复的点到树上的另一点结束而形成的路径,而路径的长度就是经过的点的数量(包括起点和终点)。而这里我们所说的单色路径自然就是只经过一种颜色的点的路径。你需要找到这棵树上最长的单色路径。 给定 阅读全文

posted @ 2016-04-20 09:38 RenewDo 阅读(588) 评论(0) 推荐(0) 编辑

2016年4月19日

Binary Tree Maximum Path Sum

摘要: 从底向上 返回值是当前连续的最大值 m是当前所有的最大值 阅读全文

posted @ 2016-04-19 22:28 RenewDo 阅读(104) 评论(0) 推荐(0) 编辑

2016年4月18日

翻转单词顺序列

摘要: class Solution { public: string reverse(string str,int i,int j) { int f=i,l=j+1-i; while(i<j) { char tmp=str[j]; str[j]=str[i]; ... 阅读全文

posted @ 2016-04-18 17:07 RenewDo 阅读(98) 评论(0) 推荐(0) 编辑

左旋转字符串

摘要: 1 class Solution { 2 public: 3 string reverse(string str,int i,int j) 4 { 5 while(istr.size())return s; 19 s=reverse(str,0,str.size()-1); 20 s=reverse(s,0,s... 阅读全文

posted @ 2016-04-18 16:29 RenewDo 阅读(138) 评论(0) 推荐(0) 编辑

和为S的两个数字

摘要: class Solution { public: vector FindNumbersWithSum(vector array,int sum) { vector res; if(array.size()sum) { last--; if(array[firs... 阅读全文

posted @ 2016-04-18 16:09 RenewDo 阅读(106) 评论(0) 推荐(0) 编辑

和为S的连续正数序列

摘要: 还是要注意几点的: 1、至少保证一个序列里有2个数 2、只有在遇到当前和大于目标值时,才递增小数,其余一律递增大数。 阅读全文

posted @ 2016-04-18 15:31 RenewDo 阅读(124) 评论(0) 推荐(0) 编辑

2016年4月17日

数组中只出现一次的数字

摘要: class Solution { public: int last1(int res) { int len=1; while(res!=0&&res>>1&1!=1) { len++; res=res>>1; } return l... 阅读全文

posted @ 2016-04-17 13:53 RenewDo 阅读(126) 评论(0) 推荐(0) 编辑

平衡二叉树

摘要: class Solution { public: int depth(TreeNode* pRoot) { if(pRoot==NULL) return 0; if(pRoot->left==NULL&&pRoot->right==NULL) return 1; els... 阅读全文

posted @ 2016-04-17 13:34 RenewDo 阅读(110) 评论(0) 推荐(0) 编辑

二叉树的深度

摘要: class Solution { public: int Tree(TreeNode* pRoot) { if(pRoot==NULL) return 0; if(pRoot->left==NULL&&pRoot->right==NULL) return 1; int dep=... 阅读全文

posted @ 2016-04-17 12:58 RenewDo 阅读(67) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 ··· 19 下一页

导航