上一页 1 2 3 4 5 6 7 8 9 ··· 21 下一页

2016年8月17日

Pow(x, n)

摘要: Implement pow(x, n) 这题用二分做,思路很明确,但是具体怎么做很有trick. 首先是n可能为INT_MIN ,如果将n直接取绝对值,则会溢出,另外,此时直接求分母,最后再求倒数,也可能在求分母的过程中溢出. 所以比较好的办法每次需要乘元素的时候乘以1/x(n<0)时. 大坑:py 阅读全文

posted @ 2016-08-17 11:45 Sheryl Wang 阅读(182) 评论(0) 推荐(0) 编辑

2016年8月16日

Insertion Sort List

摘要: Sort a linked list using insertion sort. 这道题目要求插入排序,插入排序的做法的正常做法是,对于当前要处理的数字,朝前查找在已排序数组中的位置. 对于单向链表而言,无法朝前走,所以一个替换的选择是从头朝后走.直到后面的节点值大于当前处理的节点. 值得注意的有两 阅读全文

posted @ 2016-08-16 20:29 Sheryl Wang 阅读(115) 评论(0) 推荐(0) 编辑

2016年8月15日

Word Break II

摘要: Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such p 阅读全文

posted @ 2016-08-15 21:48 Sheryl Wang 阅读(180) 评论(0) 推荐(0) 编辑

Decode Ways

摘要: A message containing letters from A-Z is being encoded to numbers using the following mapping: Given an encoded message containing digits, determine t 阅读全文

posted @ 2016-08-15 15:25 Sheryl Wang 阅读(117) 评论(0) 推荐(0) 编辑

Substring with Concatenation of All Words I

摘要: 如题,这题需要思考的是复杂度 阅读全文

posted @ 2016-08-15 11:19 Sheryl Wang 阅读(108) 评论(0) 推荐(0) 编辑

2016年8月12日

Generate Parentheses

摘要: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: 这 阅读全文

posted @ 2016-08-12 14:16 Sheryl Wang 阅读(122) 评论(0) 推荐(0) 编辑

Letter Combinations of a Phone Number

摘要: Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telepho 阅读全文

posted @ 2016-08-12 10:33 Sheryl Wang 阅读(149) 评论(0) 推荐(0) 编辑

2016年8月7日

SubTree

摘要: You have two every large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of 阅读全文

posted @ 2016-08-07 17:33 Sheryl Wang 阅读(145) 评论(0) 推荐(0) 编辑

Odd Even Linked List

摘要: Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文

posted @ 2016-08-07 11:18 Sheryl Wang 阅读(120) 评论(0) 推荐(0) 编辑

Partition Array by Odd and Even

摘要: Partition an integers array into odd number first and even number second. 剑指offer的一道题,把所有奇数移动到偶数前面,其实是partition的双端解法,利用双指针。先检测两边合格的元素,都不合格,则交换,继续。 需要注 阅读全文

posted @ 2016-08-07 11:03 Sheryl Wang 阅读(190) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 ··· 21 下一页

导航