Implement atoi to convert a string to an integer.
分类:
其他好文 时间:
2014-06-27 12:08:39
阅读次数:
143
【题目】
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 using extra memory?
【题意】
给定一个整数数组,其中除了一个数以外,其他数都是成对出现的,...
分类:
其他好文 时间:
2014-06-26 10:13:27
阅读次数:
254
题目:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the v...
分类:
其他好文 时间:
2014-06-25 14:12:42
阅读次数:
214
题目链接:uva 10843 - Anne's game
题目大意:给出n,问说有n个节点构成的标号树有多少种。
解题思路:cayley定理的躶题。
#include
#include
typedef long long ll;
const ll MOD = 2000000011;
ll Pow (ll x, ll n) {
if (n 0)
ret...
分类:
其他好文 时间:
2014-06-24 23:46:31
阅读次数:
239
题目
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possibl...
分类:
其他好文 时间:
2014-06-24 23:14:28
阅读次数:
238
题目
Implement pow(x, n).
解答
直接用递归法:
//递归法("折半"递归,不要用常规的一个个乘,效率很低)
public class Solution {
public double pow(double x, int n) {
if(n==0)
return 1;
if(n==1)
...
分类:
其他好文 时间:
2014-06-24 21:14:37
阅读次数:
199
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 ...
分类:
其他好文 时间:
2014-06-24 17:25:41
阅读次数:
197
Given an array of integers, every element appears three times except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without u...
分类:
其他好文 时间:
2014-06-24 15:52:58
阅读次数:
222