要判断是否会溢出,这点注意一下例如1123456789 反转过来就会超int.int reverse(int x) { int cur = abs(x);long long ans = 0; int result = 0; while(cur){ result = r...
分类:
其他好文 时间:
2015-03-09 14:22:54
阅读次数:
127
这是天津大学2015考研的编程题Problem DescriptionIgnatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should ...
分类:
其他好文 时间:
2015-03-09 14:17:07
阅读次数:
248
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), retur...
分类:
移动开发 时间:
2015-03-09 14:15:03
阅读次数:
128
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-03-09 12:39:01
阅读次数:
171
uint32_t reverseBits(uint32_t n) { int k = 0; uint32_t result = 0; while(n){ result+=((n%2)>=1; k++; } return result;}
分类:
其他好文 时间:
2015-03-08 21:21:29
阅读次数:
137
标题:Add Two Numbers通过率:22.6%难度:中等You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each ...
分类:
其他好文 时间:
2015-03-08 21:19:22
阅读次数:
123
标题:Reverse Bits通过率:27.6%难度:简单Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as0000001010010...
分类:
其他好文 时间:
2015-03-08 20:07:28
阅读次数:
120
Reverse bits of a given 32 bits unsigned integer.
归并法
class Solution {
public:
uint32_t reverseBits(uint32_t n) {
n=(n>>16)|(n<>8)|((n&0x00ff00ff)<<8);...
分类:
其他好文 时间:
2015-03-08 18:53:49
阅读次数:
137
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-03-08 10:26:05
阅读次数:
1355
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 ...
分类:
其他好文 时间:
2015-03-08 00:02:05
阅读次数:
193