Pow(x, n) Implement pow(x, n).SOLUTION 1:使用二分法。1. 负数的情况,使用以下的公式转化为求正数power,另外,考虑到MIN_VALUE可能会造成越界的情况,我们先将负数+1:X^(-n) = X^(n + 1) * XX^n = 1/(x^(-n))2....
分类:
其他好文 时间:
2014-12-19 21:53:05
阅读次数:
217
Minimum Subarray原题链接: http://lintcode.com/zh-cn/problem/minimum-subarray/#Given an array of integers, find the subarray with smallest sum.Return the s...
分类:
其他好文 时间:
2014-12-19 19:05:04
阅读次数:
250
Subarray Sum 原题链接:http://lintcode.com/zh-cn/problem/subarray-sum/#Given an integer array, find a subarray where the sum of numbers is zero. Your code ...
分类:
其他好文 时间:
2014-12-19 19:02:40
阅读次数:
357
【题目】
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
For example:
Given "25525511135",
return ["255.255.11.135", "255.255.111.35"...
分类:
其他好文 时间:
2014-12-19 17:26:18
阅读次数:
117
Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the be...
分类:
其他好文 时间:
2014-12-18 23:37:42
阅读次数:
417
Binary Tree Postorder Traversal Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ ...
分类:
其他好文 时间:
2014-12-18 23:31:30
阅读次数:
236
Path SumGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the give...
分类:
其他好文 时间:
2014-12-18 22:11:57
阅读次数:
157
Sum Root to Leaf Numbers Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-t...
分类:
其他好文 时间:
2014-12-18 22:11:40
阅读次数:
206
Balanced Binary Tree Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tr...
分类:
其他好文 时间:
2014-12-18 22:05:21
阅读次数:
180
这题真是过了n年才a。最早是在2010年北大培训比赛上看到的这题,当时我不会,竹教主也不会,但他记下来了,研究一段时间后就会了,还把这题加到我校oj上。过了这么多年,我上网搜,关于这个问题的解题报告还是没有,于是我花了几天时间做了出来,发布此解题报告。题目是要求从1到n的所有数与n的最小公倍数的和,...
分类:
其他好文 时间:
2014-12-18 22:00:23
阅读次数:
477