摘要: Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.合并k个排序列表解题思路是:取出 k个元素进行堆排序,每次取出最小的元素,插入链表中即可注意本题利用了c++... 阅读全文
posted @ 2014-07-01 23:17 OpenSoucre 阅读(602) 评论(0) 推荐(0) 编辑
摘要: 题目大致意思是给出n个排序list,每个list只有两个方法(1)bool goNext(); 判断是否有下一个元素,没有元素返回false, 有元素返回true(2)int next(); 返回下一个链表的值求这个n个排序链表的交集,也就是每个链表都有的元素本题的基本思路是 阅读全文
posted @ 2014-07-01 22:24 OpenSoucre 阅读(337) 评论(0) 推荐(0) 编辑
摘要: Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文
posted @ 2014-07-01 21:41 OpenSoucre 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ... 阅读全文
posted @ 2014-07-01 21:20 OpenSoucre 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1... 阅读全文
posted @ 2014-07-01 20:52 OpenSoucre 阅读(197) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum =... 阅读全文
posted @ 2014-07-01 20:12 OpenSoucre 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo... 阅读全文
posted @ 2014-07-01 19:41 OpenSoucre 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2014-07-01 18:46 OpenSoucre 阅读(117) 评论(0) 推荐(0) 编辑