2014年12月3日

Reverse Linked List II

摘要: Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No... 阅读全文

posted @ 2014-12-03 20:43 code#swan 阅读(96) 评论(0) 推荐(0)

Restore IP Addresses

摘要: Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.2... 阅读全文

posted @ 2014-12-03 20:42 code#swan 阅读(119) 评论(0) 推荐(0)

Unique Binary Search Trees II

摘要: Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni... 阅读全文

posted @ 2014-12-03 20:41 code#swan 阅读(142) 评论(0) 推荐(0)

Interleaving String

摘要: Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="... 阅读全文

posted @ 2014-12-03 20:39 code#swan 阅读(126) 评论(0) 推荐(0)

Recover Binary Search Tree

摘要: Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ... 阅读全文

posted @ 2014-12-03 20:38 code#swan 阅读(123) 评论(0) 推荐(0)

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... 阅读全文

posted @ 2014-12-03 20:37 code#swan 阅读(129) 评论(0) 推荐(0)

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... 阅读全文

posted @ 2014-12-03 20:35 code#swan 阅读(118) 评论(0) 推荐(0)

Minimum Depth of Binary Tree

摘要: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le... 阅读全文

posted @ 2014-12-03 20:34 code#swan 阅读(110) 评论(0) 推荐(0)

Path Sum

摘要: 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-12-03 20:33 code#swan 阅读(81) 评论(0) 推荐(0)

Flatten Binary Tree to Linked List

摘要: Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t... 阅读全文

posted @ 2014-12-03 20:32 code#swan 阅读(107) 评论(0) 推荐(0)

导航