Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321思路:要注意溢出。用以下做法,会溢出。class Solution {public: int reverse(in...
分类:
其他好文 时间:
2015-07-15 16:40:17
阅读次数:
83
Array:数组push:往数组末尾添加值,可以是一个或者多个。 alert(arr.push(4, 5))join:连接数组元素,中间有分隔符。 var str = arr.join(" "); alert(str);reverse:点到数组的顺序,是操作本身。 alert(arr.rev...
分类:
编程语言 时间:
2015-07-15 01:17:32
阅读次数:
261
翻转节点
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the end should remain ...
分类:
其他好文 时间:
2015-07-14 22:40:56
阅读次数:
165
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-07-14 17:21:41
阅读次数:
109
//将list存入vector,然后翻转中间部分数列
class Solution {
public:
ListNode* reverseBetween(ListNode* head, int m, int n) {
vector node;
ListNode* cur = head;
for(int i=0;i
...
分类:
其他好文 时间:
2015-07-14 10:12:31
阅读次数:
109
Question:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100)...
分类:
其他好文 时间:
2015-07-13 20:25:01
阅读次数:
93
Reverse a singly linked list.思路:新建一个ListNode,最后返回这个ListNode.next。中间使用两个临时指针一个指向原来的链表头,一个指向新的链表的next.每次循环都往里面插入新的tempNode.时间复杂度:O(n)代码: public ListN...
分类:
其他好文 时间:
2015-07-13 15:29:45
阅读次数:
138
题目描述:
输入一个五位以内(包括5位)的正整数,(1)判断它是一个几位数;(2)逆序输出其各位数字。
输入:多组数据,每组一行
输出:对应一行输出
样例输入:56439
样例输出:5 93465
解题思路:使用StringBuffer的reverse方法即可。...
分类:
其他好文 时间:
2015-07-13 12:24:51
阅读次数:
127
链表数据结构public class ListNode { public int val; public ListNode next; public ListNode(int x) { val = x; }}反转代码public ListNode reverse...
分类:
编程语言 时间:
2015-07-13 11:59:35
阅读次数:
129
字符串反转
#include "stdafx.h"
#include
using namespace std;
char*reverse_str(char*str);
int _tmain(int argc, _TCHAR* argv[])
{
char*str = "abcdefgh";
char*dst = reverse_str(str);
cout << dst << ...
分类:
其他好文 时间:
2015-07-12 12:45:18
阅读次数:
124