题解 | #在二叉树中找到两个节点的最近公共祖先#

和为S的连续正数序列

http://www.nowcoder.com/practice/c451a3fd84b64cb19485dad758a55ebe

import java.util.; public class Solution{ public ArrayList<ArrayList> FindContinuousSequence(int sum){ ArrayList<ArrayList> result = new ArrayList<>(); if(sum < 3) return result; int low = 1,high = 2; while(high > low){ int cur = (high + low)(high - low +1) / 2; if(cur == sum){ ArrayList list = new ArrayList<>(); for(int i = low;i <= high;i++){ list.add(i); } result.add(list); low ++; }else if(cur < sum){ high ++; }else{ low ++; } } return result;

}

}

我居南半坡 文章被收录于专栏

多刷题,积蓄力量,欢迎讨论

全部评论

相关推荐

许愿求offer:要有钩子,项目描述里必须有一两个让面试官忍不住想问的技术点
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务