Q:Determine whether an integer is a palindrome. Do this without extra space.
这道题也是基础题,判断一个数是否是回文数,条件是不能使用额外的空间,意思就是说,你不能把一个Intege转换成string,然后对string进行回文字符串的判断。
另外,如果用Reverse Integer的方法,可能会造成数值溢出,比如判...
分类:
其他好文 时间:
2015-01-31 12:31:11
阅读次数:
169
上界2147483647-, 下界2147483648. 反过来看7463847412 -> 2147483647, -8463847412 -> -2147483648为使反转不越界,那么绝对值大于10^9的参数x的前9位应满足 2147483647. (参数x,本身没有越界,所以d肯定是1或2....
分类:
其他好文 时间:
2015-01-30 20:54:36
阅读次数:
127
做个应用界面,需要批量查地址和ip,各地图网站一般都支持geocoding web api。
主要用到两个服务接口:geocode(把街道名转换成gps位置),reverse(把gps地址转换成街道名地址)...
分类:
其他好文 时间:
2015-01-30 19:45:55
阅读次数:
200
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link...
分类:
其他好文 时间:
2015-01-30 15:55:05
阅读次数:
196
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a l...
分类:
其他好文 时间:
2015-01-30 10:55:06
阅读次数:
293
原题地址将单词按空格分词,然后倒序拼接即可代码: 1 void reverseWords(string &s) { 2 vector words; 3 4 int start = -1; 5 int len = 0; 6 ...
分类:
其他好文 时间:
2015-01-30 10:30:11
阅读次数:
157
Areversibleprimeinanynumbersystemisaprimewhose"reverse"inthatnumbersystemisalsoaprime.Forexampleinthedecimalsystem73isareversibleprimebecauseitsrevers...
分类:
其他好文 时间:
2015-01-30 07:52:34
阅读次数:
145
原题地址基本栈操作。注意数字有可能是负的。代码: 1 int toInteger(string &s) { 2 int res = 0; 3 bool negative = s[0] == '-' ? true : false; 4 5 for (int i = neg...
分类:
其他好文 时间:
2015-01-29 20:56:23
阅读次数:
164
B - Reverse Root
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit Status
Description
The problem is so easy, that the authors were lazy to write a ...
分类:
其他好文 时间:
2015-01-29 14:38:16
阅读次数:
99
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321解法一:public class Solution { public int reverse(int x) { ...
分类:
其他好文 时间:
2015-01-29 00:00:26
阅读次数:
313