码迷,mamicode.com
首页 >  
搜索关键字:swap nodes in pairs    ( 8848个结果
Leetcode Binary Tree Inorder Traversal
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:其他好文   时间:2014-07-02 22:49:05    阅读次数:249
[leetcode] Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
分类:其他好文   时间:2014-07-02 10:01:21    阅读次数:173
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. 代码如下: * Definition for singly-linked list. * struct L...
分类:其他好文   时间:2014-07-02 07:23:59    阅读次数:159
HDU 2923 Einbahnstrasse
英语渣就是这点不好。。。 巨恶心这种描述多的题。。 大意就是求 从一个点出发,到某些点,然后又从那些点返回的距离之和的 最小值。 Dijkstra+邻接矩阵。 正向建图,求出出发距离,然后swap边,求出 返回距离。 注意的是 车可能有重复的。某个点有多少车就需要乘以车的数量。 #include #include #include #include #in...
分类:其他好文   时间:2014-07-02 07:16:49    阅读次数:253
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,...
分类:其他好文   时间:2014-07-01 12:44:09    阅读次数:199
leetcode题解:Tree Level Order Traversal II (二叉树的层序遍历 2)
题目: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 ...
分类:其他好文   时间:2014-07-01 12:26:07    阅读次数:215
[Leetcode]Add Two Numbers
题目 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 digit. Add the two numbers and return it a...
分类:其他好文   时间:2014-07-01 09:11:07    阅读次数:206
Reorder List
题目 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}, re...
分类:其他好文   时间:2014-07-01 08:39:24    阅读次数:181
Binary Tree Preorder Traversal
题目 Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 2 / 3 return [1,2,3]. Note: Recu...
分类:其他好文   时间:2014-07-01 07:06:56    阅读次数:177
Binary Tree Postorder Traversal
题目 Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 2 / 3 return [3,2,1]. Note: Rec...
分类:其他好文   时间:2014-07-01 07:06:11    阅读次数:214
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!