题意:给定一个无符号32位整数,将其二进制形式左右反置,再以整型返回。思路:循环32轮,将n往右挤出一位就补到ans的尾巴上。 1 class Solution { 2 public: 3 uint32_t reverseBits(uint32_t n) { 4 if( !n...
分类:
其他好文 时间:
2015-04-10 01:07:34
阅读次数:
109
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321题目很简单,先判断数字的正负,再按位倒置数字就可以了。不过要考虑int的上限。代码如下:class Solution {pub...
分类:
其他好文 时间:
2015-04-09 23:14:39
阅读次数:
110
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-04-09 15:16:42
阅读次数:
103
题目链接:Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:
Given 1->2->3->4->5->NULL, m = 2 and n = 4,
return 1->4->3->2->5->NULL.
Note:
...
分类:
其他好文 时间:
2015-04-09 11:57:57
阅读次数:
209
题目: 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 sin...
分类:
其他好文 时间:
2015-04-09 06:20:09
阅读次数:
147
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-04-08 22:55:54
阅读次数:
142
描述: 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 sin...
分类:
其他好文 时间:
2015-04-08 21:15:14
阅读次数:
107
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-04-08 21:10:38
阅读次数:
108
DescriptionGiven a sequence, {A1, A2, …, An} which is guaranteed A1 > A2, …, An, you are to cut it into three sub-sequences and reverse them separately to form a new one which is the smallest possible...
分类:
编程语言 时间:
2015-04-08 16:28:10
阅读次数:
195
和I 比起来其实很不一样,反而很类似于linkedlist reverse,不断的看pre.next的东西,我自己想了好久,开始用三个指针,完全糊涂,还是退回到原来的code,才明了public class Solution { public ListNode deleteDuplicates...
分类:
其他好文 时间:
2015-04-08 12:24:47
阅读次数:
95