题目:Reverse a linked list from positionmton. Do it
in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m=
2 andn= 4,return1->4->3->2->5->NULL...
分类:
其他好文 时间:
2014-06-09 23:03:18
阅读次数:
254
原题地址:https://oj.leetcode.com/problems/simplify-path/题意:Given
an absolute path for a file (Unix-style), simplify it.For example,path="/home/",
=>"/home...
分类:
编程语言 时间:
2014-06-09 19:13:54
阅读次数:
181
//定义二维平面上的点struct Point{ int x; int y;
Point(int a=0, int b=0):x(a),y(b){}};bool operator==(const Point& left,
const Point& right){ return...
分类:
其他好文 时间:
2014-06-08 22:26:17
阅读次数:
357
原题地址:https://oj.leetcode.com/problems/sqrtx/题意:Implementint
sqrt(int x).Compute and return the square root
ofx.解题思路:实现开平方函数。这里要注意的一点是返回的时一个整数。通过这一点我们可...
分类:
编程语言 时间:
2014-06-08 21:04:38
阅读次数:
329
原题地址:https://oj.leetcode.com/problems/search-for-a-range/题意:Given
a sorted array of integers, find the starting and ending position of a given
target ...
分类:
编程语言 时间:
2014-06-08 21:03:21
阅读次数:
297
原题地址:https://oj.leetcode.com/problems/sort-colors/题意:Given
an array withnobjects colored red, white or blue, sort them so that objects of
the same col...
分类:
编程语言 时间:
2014-06-08 20:56:32
阅读次数:
394
原题地址:https://oj.leetcode.com/problems/add-binary/题意:Given
two binary strings, return their sum (also a binary string).For example,a ="11"b
="1"Return"...
分类:
编程语言 时间:
2014-06-08 20:28:04
阅读次数:
300
题目来源:Light OJ 1278 Sum of Consecutive Integers
题意:N拆分成连续整数和的方案数
思路:奇因数的个数
#include
#include
#include
#include
using namespace std;
//筛素数
const int maxn = 10000010;
bool vis[maxn];
int prime[10...
分类:
其他好文 时间:
2014-06-08 15:34:09
阅读次数:
295
题目来源:Light OJ 1026 Critical Links
题意:输出桥
思路:模版
#include
#include
#include
#include
#include
using namespace std;
const int maxn = 10010;
struct Edge
{
int u, v;
Edge(){}
Edge(int u, int v):...
分类:
其他好文 时间:
2014-06-08 04:07:05
阅读次数:
235
题目来源:Light OJ 1291 Real Life Traffic
题意:最少添加几条边 可以使全图边双连通
思路:缩点 重新构图 答案就是(叶子节点数+1)/ 2
#include
#include
#include
#include
#include
using namespace std;
const int maxn = 10010;
struct Edge
{
i...
分类:
其他好文 时间:
2014-06-08 02:57:26
阅读次数:
276