随笔分类 -  leetcode

摘要:Valid SudokuDetermine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are ... 阅读全文
posted @ 2015-01-29 15:28 imKirin 阅读(147) 评论(0) 推荐(0)
摘要:Count and SayThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is r... 阅读全文
posted @ 2015-01-27 22:04 imKirin 阅读(187) 评论(0) 推荐(0)
摘要:Decode WaysA message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded me... 阅读全文
posted @ 2015-01-26 18:51 imKirin 阅读(175) 评论(0) 推荐(0)
摘要:Sqrt(x)Implementint sqrt(int x).Compute and return the square root ofx.分析:方案一:遍历0~n, 第一次出现i * i > n,返回 i-1即可。方案二:二分搜索: (1) 当n = 0, 或者 n = 1时,返回 n (2... 阅读全文
posted @ 2015-01-26 12:39 imKirin 阅读(215) 评论(0) 推荐(0)
摘要:Best Time to Buy and Sell Stock IISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the ... 阅读全文
posted @ 2015-01-25 17:52 imKirin 阅读(116) 评论(0) 推荐(0)
摘要:Unique Binary Search TreesGivenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a to... 阅读全文
posted @ 2015-01-25 13:44 imKirin 阅读(127) 评论(0) 推荐(0)
摘要:AnagramsGiven an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.anagrams特点:单词里的字母的种类和数目是一样的,只... 阅读全文
posted @ 2015-01-24 16:34 imKirin 阅读(136) 评论(0) 推荐(0)
摘要:Valid NumberValidate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the ... 阅读全文
posted @ 2015-01-24 10:43 imKirin 阅读(131) 评论(0) 推荐(0)