摘要: 题目:数组中有一个数字的次数超过数组长度的一半,请找出这个数字。解法一:基于Partition函数的O(N)算法 1 int partition(vector&num, int low, int high) 2 { 3 int pivot = num[low]; 4 while (l... 阅读全文
posted @ 2015-07-04 20:32 Rosanne 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 题目:输入一棵二叉树和一个整数,打印出二叉树中结点值的和为输入整数的所有路径。从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。参见Leetcode-Path Sum II。 阅读全文
posted @ 2015-07-04 17:41 Rosanne 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Description:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary t... 阅读全文
posted @ 2015-07-04 17:35 Rosanne 阅读(178) 评论(0) 推荐(0) 编辑