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
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-03-07 21:18:26
阅读次数:
121
1 题目Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Have you thought about this?Here are...
分类:
其他好文 时间:
2015-03-06 23:25:23
阅读次数:
164
Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers.
Some hints: Could negative integers be palindromes?...
分类:
其他好文 时间:
2015-03-06 14:14:56
阅读次数:
111
将一个整数颠倒 基本思路:用一个标志位记录整数的符号,如果是负数转换成整数后颠倒,然后再乘以-1。本题主要考虑的是溢出。 注意点: 负数到正数的过程中存在溢出 数字颠倒后存在溢出 class Solution {public: int reverse(int x) { long long res =...
分类:
其他好文 时间:
2015-03-06 09:54:24
阅读次数:
150
Oracle提供了一个反转倒置函数reverse,但此函数不能分组倒置,本文提供了一个即可分组倒置的函数,如下所示:
CREATE OR REPLACE FUNCTION REVERSE_F(p_str VARCHAR2, p_delimiter VARCHAR2:=',')
RETURN VARCHAR2 IS
v_return VARCHAR2(4000);
vp_str...
分类:
数据库 时间:
2015-03-05 19:31:10
阅读次数:
208
[LeetCode] 025. Reverse Nodes in k-Group (Hard) (C++/Java)...
分类:
编程语言 时间:
2015-03-05 17:11:32
阅读次数:
176
将一个长度为n的数组循环右移k次 注意点: k有可能大于n,需要取余。 需要考虑空间开销,存在空间开销为O(1)的解法 需要考虑时间开销 比较巧妙的方法是利用STL内置的reverse函数,做三次即可。举个例子:array[7]={1,2,3,4,5,6,7},n=3 7,6,5,4,3,2,1 5...
分类:
其他好文 时间:
2015-03-05 16:13:38
阅读次数:
285