2015年1月13日

[leetcode] Letter Combinations of a Phone Number

摘要: Letter Combinations of a Phone NumberGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit ... 阅读全文

posted @ 2015-01-13 13:20 cha1992 阅读(111) 评论(0) 推荐(0) 编辑

2015年1月12日

[leetcode] Pow(x, n)

摘要: Pow(x, n)Implement pow(x,n).思路:分治算法,2^4=(2^2)*(2^2)。整体的思路就是这样,要注意考虑n为负数的情况。我的做法是在写一个函数计算乘方,原来的函数根据n的正负选择如何调用power函数。开始的时候,没有用tmp保存power(x,n/2)的值,直接写成p... 阅读全文

posted @ 2015-01-12 12:48 cha1992 阅读(161) 评论(0) 推荐(0) 编辑

2015年1月11日

[leetcode] Longest Common Prefix

摘要: Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.思路:找最长前缀,暴力法寻找。遍历整个容器,prefix记录了当前的最长前缀,将pre... 阅读全文

posted @ 2015-01-11 14:57 cha1992 阅读(121) 评论(0) 推荐(0) 编辑

2015年1月10日

[leetcode] Binary Tree Zigzag Level Order Traversal

摘要: Binary Tree Zigzag Level Order TraversalGiven a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then... 阅读全文

posted @ 2015-01-10 15:31 cha1992 阅读(121) 评论(0) 推荐(0) 编辑

2015年1月9日

[leetcode] Construct Binary Tree from Preorder and Inorder Traversal

摘要: Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume... 阅读全文

posted @ 2015-01-09 17:49 cha1992 阅读(106) 评论(0) 推荐(0) 编辑

[leetcode] Construct Binary Tree from Inorder and Postorder Traversal

摘要: Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You may assu... 阅读全文

posted @ 2015-01-09 15:18 cha1992 阅读(147) 评论(0) 推荐(0) 编辑

2015年1月8日

[leetcode] Triangle

摘要: TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given... 阅读全文

posted @ 2015-01-08 12:14 cha1992 阅读(185) 评论(0) 推荐(0) 编辑

2015年1月6日

[leetcode] Subsets II

摘要: Subsets IIGiven a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descend... 阅读全文

posted @ 2015-01-06 19:32 cha1992 阅读(166) 评论(0) 推荐(0) 编辑

[leetcode] Subsets

摘要: SubsetsGiven a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must... 阅读全文

posted @ 2015-01-06 17:21 cha1992 阅读(178) 评论(0) 推荐(0) 编辑

2015年1月5日

[leetcode] Excel Sheet Column Title & Excel Sheet Column Number

摘要: Excel Sheet Column TitleGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B ... 阅读全文

posted @ 2015-01-05 09:51 cha1992 阅读(179) 评论(0) 推荐(0) 编辑

导航