Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values.
For example,
Given {1,2,3,4}, reorder it t...
分类:
其他好文 时间:
2014-10-08 15:01:15
阅读次数:
159
DescriptionD Anti-Rhyme Pairs Input: Standard Input Output: Standard Output Often two words that rhyme also end in the same sequence of characters. We...
分类:
其他好文 时间:
2014-10-08 11:01:35
阅读次数:
261
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,3,2].
/**
* Definition for b...
分类:
其他好文 时间:
2014-10-08 10:45:45
阅读次数:
106
Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For exam...
分类:
编程语言 时间:
2014-10-08 01:02:44
阅读次数:
268
lock-free是一种基于原子变量类来构建的非阻塞同步算法。比较并交换(compare-and-swap)我们经常会先检查某项东西,然后对其进行修改,如if(X...) {X=...}。这种行为在多线程下并不是线程安全的。那我们该如何做呢?一种方法是对操作进行加锁,如synchornized(ob...
分类:
其他好文 时间:
2014-10-07 18:37:35
阅读次数:
151
Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For exam...
分类:
其他好文 时间:
2014-10-07 17:53:53
阅读次数:
221
不要晃荡,找准方向[问题描述]Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes a...
分类:
其他好文 时间:
2014-10-07 00:20:21
阅读次数:
208
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys less than the node's key.Th...
分类:
其他好文 时间:
2014-10-06 19:32:50
阅读次数:
173
题目:Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the ...
分类:
其他好文 时间:
2014-10-06 18:31:30
阅读次数:
145
点击打开链接
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){
if(x>y)swap(x,y);
while(x){
y%=x;
swap(...
分类:
其他好文 时间:
2014-10-06 17:49:40
阅读次数:
240