题目描述:
Implement pow(x, n).
代码:
double solution::pow(double x,int n)
{
if(n == 0)
return 1;
if(n == 1)
return x;
if(n < 0)
{
n = n * -1;
x = 1 / x;
}
return n%2==0?pow(x*x,n/2):x*p...
分类:
其他好文 时间:
2015-01-07 13:10:07
阅读次数:
119
1 : 2 Implement pow(x, n). 3 4 class Solution { 5 public: 6 double pow(double x, int n) { 7 8 //显然我们应该用类似于分治的算法pow(double x, int n) = p...
分类:
其他好文 时间:
2015-01-06 00:47:13
阅读次数:
291
题目:
Given an array of integers, every element appears three times except for one. Find that single one.
Your algorithm should have a linear runtime complexity. Could you implement it without using e...
分类:
其他好文 时间:
2015-01-05 16:41:37
阅读次数:
178
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.
get(key) - Get the value (will always be positive) of the key if...
分类:
系统相关 时间:
2015-01-05 14:54:59
阅读次数:
219
题目:
Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without us...
分类:
编程语言 时间:
2015-01-04 23:10:13
阅读次数:
286
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Update (2014-11-02):The s...
分类:
其他好文 时间:
2015-01-04 07:37:15
阅读次数:
209
沈阳463整形医院专家尽管标准的C通常在C和C++中的功能相同,但是一些函数在每个语言中有不同的符号差。标准的函数他们的符号差不同的是:strchr(), strpbrk(), strrchr(), strstr(), 和 memchr(),字符副本也和它们一样:wcschr(), wcspbr.....
分类:
编程语言 时间:
2015-01-03 17:06:13
阅读次数:
127
【题目】
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.
Calling next() will return the next smallest number in the BST.
No...
分类:
其他好文 时间:
2015-01-03 12:00:06
阅读次数:
161
https://oj.leetcode.com/problems/implement-strstr/http://fisherlei.blogspot.com/2012/12/leetcode-implement-strstr.htmlpublicclassSolution{
publicintstrStr(Stringhaystack,Stringneedle){
//遍历haystack,对每一个字符,匹配needle
if(haystack==null||needle==nu..
分类:
其他好文 时间:
2015-01-02 16:12:25
阅读次数:
149
Binary Search Tree Iterator
Total Accepted: 1141
Total Submissions: 3857
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.
...
分类:
其他好文 时间:
2015-01-02 13:28:25
阅读次数:
165