介绍给大家一个快速排序的方法:
void sort(int a[ ], int l, int r)
{
int i = l;
int j = r;
int mid = a[(i+j)/2];
do
{
while(a[i]
while(a[j] >mid ) j--;
if( i
{
swap( a[i], a[j] );
}...
分类:
编程语言 时间:
2014-06-20 13:15:03
阅读次数:
292
题目
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].
Note: Recur...
分类:
其他好文 时间:
2014-06-20 10:22:00
阅读次数:
221
【题目】
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree {3,9,20,#,#,15,7},
3
/ 9 20
/ 15 7
return its b...
分类:
其他好文 时间:
2014-06-20 09:42:30
阅读次数:
224
Merge two sorted linked lists and return it as
a new list. The new list should be made by splicing together the nodes of the
first two lists./** * Def...
分类:
其他好文 时间:
2014-06-11 22:56:31
阅读次数:
257
前言
欢迎大家我分享和推荐好用的代码段~~
声明
欢迎转载,但请保留文章原始出处:
CSDN:http://www.csdn.net
雨季o莫忧离:http://blog.csdn.net/luckkof
正文
[Description]
对于LCA 版本,通常有打开swap conf...
分类:
移动开发 时间:
2014-06-07 13:49:23
阅读次数:
267
python实现的链表,包括插入、查找、删除操作
#!/usr/bin/python
class linknode():
def __init__(self,k,n=None):
self.key=k;
self.next=n;
def createlist(): #创建链表
n=raw_input("enter the num of nodes");
n=int(...
分类:
编程语言 时间:
2014-06-07 12:23:46
阅读次数:
204
Partition ListGiven a linked list and a valuex,
partition it such that all nodes less thanxcome before nodes greater than or
equal tox.You should pres...
分类:
其他好文 时间:
2014-06-07 06:24:57
阅读次数:
179
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 l...
分类:
其他好文 时间:
2014-06-05 22:13:19
阅读次数:
391
Given a binary tree, find its maximum depth.The
maximum depth is the number of nodes along the longest path from the root node
down to the farthest le...
分类:
其他好文 时间:
2014-06-05 14:10:38
阅读次数:
304
Given a linked list, swap every two adjacent
nodes and return its head.For example,Given1->2->3->4, you should
return the list as2->1->4->3.Your algor...
分类:
其他好文 时间:
2014-06-05 13:41:44
阅读次数:
231