LeetCode第一题:Evaluate Reverse Polish Notation...
分类:
其他好文 时间:
2014-06-16 12:51:19
阅读次数:
152
原题地址:https://oj.leetcode.com/problems/reverse-nodes-in-k-group/题意:Given a linked list, reverse the nodes of a linked listkat a time and return its mod...
分类:
编程语言 时间:
2014-06-15 21:24:43
阅读次数:
293
Reverse Integer反转一个整数C++ Code1234567891011121314151617181920212223242526272829303132classSolution{public:intreverse(intx){/*一位数的情况*/if(-10=10){div*=10...
分类:
其他好文 时间:
2014-06-15 20:19:20
阅读次数:
196
真的被这道题目恶心到了。。。281行代码。。。比一个模拟题还费事。。。
为了方便起见,在数列的前面和后面都加一个0点。
add x :把第k2+2个点旋转至root1.然后sum[root10]+=x;
reverse:把第k1+2个点旋转至root1.然后rev[root10]^=1;
insert x:得到第2个点,然后在第2个点之后插入x。
delete
:把第1个点旋...
分类:
其他好文 时间:
2014-06-14 00:54:26
阅读次数:
324
2 8 5 3 11.从后往前,找到第一个逆序的数
pivot2.从后往前,找到第一个比pivot大的数 change3.交换 pivot 和 change的值4.把pivot这个位置后面的数
reverse,就是 8 5 2 1变成 1 2 5 8最终为3 1 2 5 8#include #inc...
分类:
其他好文 时间:
2014-06-13 17:38:19
阅读次数:
378
Reverse Linked List IIReverse a linked list from
positionmton. Do it in-place and in one-pass.For example:Given
1->2->3->4->5->NULL, m= 2 andn= 4,retu...
分类:
其他好文 时间:
2014-06-12 07:03:54
阅读次数:
308
题目
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:
Given m,...
分类:
其他好文 时间:
2014-06-11 06:07:11
阅读次数:
392
问题:
给定一个链表的头指针,以及一个整数k,要求将链表按每k个为一组,组内进行链表逆置。少于k个的部分不做处理。
分析:
个人觉得问题的重点是熟悉链表的就地逆置操作,就是头插法。其他的考察点如果还有的话,就的细心程度。
实现:
void reverseList(ListNode *&pre, ListNode *head)
{
ListNode *tail = NULL;
w...
分类:
其他好文 时间:
2014-06-10 17:25:45
阅读次数:
305
Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
Clarification:
What constitutes a word?
A sequence of non-space ch...
分类:
其他好文 时间:
2014-06-10 11:12:06
阅读次数:
185