码迷,mamicode.com
首页 >  
搜索关键字:swap nodes in pairs    ( 8848个结果
POJ1655——Balancing Act
Balancing Act Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9143   Accepted: 3797 Description Consider a tree T with N (1 <= N <= 20,000) nodes numbered 1......
分类:其他好文   时间:2014-11-03 13:07:38    阅读次数:167
POJ 1852 Ants
理解题意就很简单。 一条木棍上有很多蚂蚁,全都面朝木棍中间的位置爬行。 两个相遇就都掉头爬行,这可以理解为两个蚂蚁互相之间没有干扰。(swap一下)。 这样只需要找距离两头的距离就好了。 #include #include #include #include #include #include #include #include #include #include #inc...
分类:其他好文   时间:2014-11-03 13:06:52    阅读次数:141
leetcode Merge Two Sorted Lists
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.1,注意从新定义l...
分类:其他好文   时间:2014-11-03 08:55:40    阅读次数:163
Remove Duplicates from Sorted List II 移除有序链表中的重复项之二
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-...
分类:其他好文   时间:2014-11-02 13:41:39    阅读次数:168
boost准模板库scoped_ptr指针的使用以及auto_ptr智能指针的对照
首先我们看看scoped_ptr的基本使用,包括了swap(),get(),reset()的使用,重要的提醒是作用域结束的时候会自己主动析构,无需手动的释放资源:#include#includeusing namespace std;using namespace boost;struct p...
分类:其他好文   时间:2014-11-02 12:14:47    阅读次数:200
LeetCode[Linked List]: Reverse Nodes in k-Group
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 as it is. ...
分类:其他好文   时间:2014-11-02 09:27:14    阅读次数:276
leetcode Binary Tree Level Order Traversal I II
Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
分类:其他好文   时间:2014-11-02 07:06:13    阅读次数:195
[Leetcode] Binary Tree Level Order Traversal II
Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa...
分类:其他好文   时间:2014-11-02 07:04:55    阅读次数:202
Java实现交换两个String
在Java中我们所使用的实例变量其实都是一个引用,所以如果要求实现一个swap(String A, String B)这种函数时无法实现的,因为在类方法的定义中是先对行参进行地址传递,然后对形参修改,所以对原来的变量不产生影响。一种实现方法是不使用方法传递参数,直接交换,另一种有趣的方式是使用Jav...
分类:编程语言   时间:2014-11-02 07:03:51    阅读次数:174
[Leetcode] Binary Tree Level Order Traversal
Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
分类:其他好文   时间:2014-11-02 07:01:30    阅读次数:210
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!