LRU CacheDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get...
分类:
系统相关 时间:
2014-11-21 18:21:45
阅读次数:
238
Implement int sqrt(int x).
Compute and return the square root of x.
原题链接:https://oj.leetcode.com/problems/sqrtx/
使用二分法来解题。
public int sqrt(int x) {
if(x == 0 || x== 1)
return x;
in...
分类:
其他好文 时间:
2014-11-21 16:24:07
阅读次数:
175
Implement pow(x,n).C++实现代码:#includeusing namespace std;class Solution{public: double pow(double x, int n) { if(x==0&&n==0) ret...
分类:
其他好文 时间:
2014-11-21 10:36:20
阅读次数:
147
1> 类访问修饰符修饰符class类名称extends父类名称implement接口名称(访问修饰符与修饰符的位置可以互换)访问修饰符名称说明备注public可以被所有类访问(使用)public类必须定义在和类名相同的同名文件中package可以被同一个包中的类访问(使用)默认的访问权限,可以省略此...
分类:
编程语言 时间:
2014-11-20 16:57:25
阅读次数:
287
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu...
分类:
系统相关 时间:
2014-11-20 13:39:25
阅读次数:
289
LRU CacheDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get...
分类:
系统相关 时间:
2014-11-19 20:29:44
阅读次数:
289
一道LeetCode OJ上的题目,要求设计一个LRU(Least Recently Used)算法,题目描述如下:Design and implement a data structure for Least Recently Used (LRU) cache. It should support...
分类:
编程语言 时间:
2014-11-19 13:51:25
阅读次数:
222
Implement pow(x, n).
原题链接:https://oj.leetcode.com/problems/powx-n/
public double pow(double x, int n) {
if(n== 0)
return 1;
if(n == 1)
return x;
if(n % 2 ==0)
return pow(x*x,n/2);
...
分类:
其他好文 时间:
2014-11-19 11:19:53
阅读次数:
135
Implement pow(x, n).
原题链接:https://oj.leetcode.com/problems/powx-n/
public double pow(double x, int n) {
if(n== 0)
return 1;
if(n == 1)
return x;
if(n % 2 ==0)
return pow(x*x,n/2);
...
分类:
其他好文 时间:
2014-11-19 01:19:41
阅读次数:
157
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 si...
分类:
其他好文 时间:
2014-11-18 23:34:46
阅读次数:
180