描述:数组元素个数为n,右移k位,如12345,右移3位后是34512解答思路:将12345全旋转得到54321 将前3位旋转34521 将后两位旋转34512处理核心是旋转reverse(vector &nums,int begin,int end)旋转分隔点是k=k%n(k是移动...
分类:
编程语言 时间:
2015-05-07 10:22:17
阅读次数:
139
题目在这里:https://leetcode.com/problems/evaluate-reverse-polish-notation/【标签】Stack【题目分析】思路就不多说了吧,大概就是,遇到数字这样的operand, 就先压到栈里面;遇到 +, -, *, / 的话,就可以进行局部的运算了...
分类:
编程语言 时间:
2015-05-07 06:25:27
阅读次数:
143
绝对老题了,感觉已经重复了Reverse a singly linked list.click to show more hints.Hint:A linked list can be reversed either iteratively or recursively. Could you imp...
分类:
其他好文 时间:
2015-05-06 20:56:52
阅读次数:
124
题目:
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-05-06 18:03:38
阅读次数:
132
此次blog会将leetcode上的linklist专题内容放在这里,后续慢慢添加
一:leetcode 206 Reverse
Linked List 二:leetcode 92 Reverse
Linked List II
一:leetcode 206 Reverse
Linked List
题目:
Reverse a singly linked list.
代码:...
分类:
其他好文 时间:
2015-05-06 17:54:05
阅读次数:
124
题目链接:点击打开链接
题意:给定一个图包含n个点,m条容量为1的有向边,问只翻转一条边能使s到t的最大流增大到多少?有多少种方法?
思路:先跑一遍最大流,在残余流量里把点分为为两个集合,第一个集合包含所有从起点能到达的点,第二个集合包含所有能到达终点的点,那么答案就是起点在第二个集合终点在第一个集合的边的条数(两个集合都不包含的点忽略)。
cpp代码:
#include
#includ...
分类:
其他好文 时间:
2015-05-06 17:39:55
阅读次数:
135
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-05-06 14:44:07
阅读次数:
105
题目Reverse a singly linked list....
分类:
其他好文 时间:
2015-05-06 11:01:23
阅读次数:
111
Reverse Linked List2015.5.6 05:04Reverse a singly linked list.Solution: Too old.Accepted code: 1 // 1CE, 1AC, not perfect 2 /** 3 * Definition for s.....
分类:
其他好文 时间:
2015-05-06 06:55:41
阅读次数:
123
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C prog...
分类:
其他好文 时间:
2015-05-06 01:07:01
阅读次数:
123