随笔分类 -  Algorithm

上一页 1 2 3 4 5 6 ··· 14 下一页

[LeetCode] First Bad Version
摘要:First Bad VersionYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fa... 阅读全文

posted @ 2015-09-07 21:11 Eason Liu 阅读(282) 评论(0) 推荐(1)

[LeetCode] Missing Ranges
摘要:Missing RangesGiven a sorted integer array where the range of elements are [lower,upper] inclusive, return its missing ranges.For example, given[0, 1,... 阅读全文

posted @ 2015-09-07 13:07 Eason Liu 阅读(212) 评论(0) 推荐(0)

[LeetCode] Find the Celebrity
摘要:Find the CelebritySuppose you are at a party withnpeople (labeled from0ton - 1) and among them, there may exist one celebrity. The definition of a cel... 阅读全文

posted @ 2015-09-06 13:11 Eason Liu 阅读(7177) 评论(0) 推荐(0)

[LeetCode] Longest Substring with At Most Two Distinct Characters
摘要:Longest Substring with At Most Two Distinct CharactersGiven a string, find the length of the longest substring T that contains at most 2 distinct char... 阅读全文

posted @ 2015-09-06 11:37 Eason Liu 阅读(201) 评论(0) 推荐(0)

[LeetCode] Read N Characters Given Read4 I & II
摘要:Read N Characters Given Read4The API:int read4(char *buf)reads 4 characters at a time from a file.The return value is the actual number of characters ... 阅读全文

posted @ 2015-09-06 11:33 Eason Liu 阅读(617) 评论(0) 推荐(0)

[LeetCode] Meeting Rooms I & II
摘要:Meeting RoomsGiven an array of meeting time intervals consisting of start and end times[[s1,e1],[s2,e2],...](si& intervals) {13 sort(intervals... 阅读全文

posted @ 2015-09-06 11:29 Eason Liu 阅读(375) 评论(0) 推荐(0)

[LeetCode] Graph Valid Tree
摘要:Graph Valid TreeGivennnodes labeled from0ton - 1and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these... 阅读全文

posted @ 2015-09-06 11:17 Eason Liu 阅读(542) 评论(0) 推荐(0)

[LeetCode] Palindrome Permutation I & II
摘要:Palindrome PermutationGiven a string, determine if a permutation of the string could form a palindrome.For example,"code"-> False,"aab"-> True,"carera... 阅读全文

posted @ 2015-09-06 11:12 Eason Liu 阅读(930) 评论(0) 推荐(0)

[LeetCode] Encode and Decode Strings
摘要:Encode and Decode StringsDesign an algorithm to encodea list of stringstoa string. The encoded string is then sent over the network and is decoded bac... 阅读全文

posted @ 2015-09-06 11:08 Eason Liu 阅读(1456) 评论(0) 推荐(0)

[LeetCode] Paint Fence
摘要:Paint FenceThere is a fence with n posts, each post can be painted with one of the k colors.You have to paint all the posts such that no more than two... 阅读全文

posted @ 2015-09-06 11:01 Eason Liu 阅读(1206) 评论(0) 推荐(0)

[LeetCode] Paint House I & II
摘要:Paint HouseThere are a row ofnhouses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with... 阅读全文

posted @ 2015-09-06 10:56 Eason Liu 阅读(2212) 评论(0) 推荐(0)

[LeetCode] Shortest Word Distance I & II & III
摘要:Shortest Word DistanceGiven a list of words and two wordsword1andword2, return the shortest distance between these two words in the list.For example,A... 阅读全文

posted @ 2015-09-06 10:51 Eason Liu 阅读(2139) 评论(0) 推荐(0)

[LeetCode] Integer to English Words
摘要:Integer to English WordsConvert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231- 1.For examp... 阅读全文

posted @ 2015-08-31 12:18 Eason Liu 阅读(903) 评论(0) 推荐(0)

[CTCI] 最长合成字符串
摘要:最长合成字符串题目描述有一组单词,请编写一个程序,在数组中找出由数组中字符串组成的最长的串A,即A是由其它单词组成的(可重复)最长的单词。给定一个string数组str,同时给定数组的大小n。请返回最长单词的长度,保证题意所述的最长单词存在。测试样例:["a","b","c","ab","bc","... 阅读全文

posted @ 2015-08-19 23:49 Eason Liu 阅读(544) 评论(0) 推荐(0)

[LintCode] Trapping Rain Water II
摘要:Trapping Rain Water IIGivennxmnon-negative integers representing an elevation map 2d where the area of each cell is1x1, compute how much water it is a... 阅读全文

posted @ 2015-08-19 22:15 Eason Liu 阅读(2301) 评论(0) 推荐(0)

[LintCode] Coins in a Line III
摘要:Coins in a Line IIIThere arencoins in a line. Two players take turns to take a coin from one of the ends of the line until there are no more coins lef... 阅读全文

posted @ 2015-08-18 23:47 Eason Liu 阅读(2319) 评论(0) 推荐(0)

[CTCI] 子串判断
摘要:子串判断题目描述现有一个小写英文字母组成的字符串s和一个包含较短小写英文字符串的数组p,请设计一个高效算法,对于p中的每一个较短字符串,判断其是否为s的子串。给定一个string数组p和它的大小n,同时给定strings,为母串,请返回一个bool数组,每个元素代表p中的对应字符串是否为s的子串。保... 阅读全文

posted @ 2015-07-30 21:39 Eason Liu 阅读(542) 评论(0) 推荐(0)

[CTCI] 最大子方阵
摘要:最大子方阵题目描述有一个方阵,其中每个单元(像素)非黑即白(非0即1),请设计一个高效算法,找到四条边颜色相同的最大子方阵。给定一个01方阵mat,同时给定方阵的边长n,请返回最大子方阵的边长。保证方阵变长小于等于100。测试样例:[[1,1,1],[1,0,1],[1,1,1]],3返回:3要看清... 阅读全文

posted @ 2015-07-30 21:27 Eason Liu 阅读(865) 评论(0) 推荐(0)

[LintCode] Number of Islands II
摘要:Number of Islands IIGiven a n,m which means the row and column of the 2D matrix and an array of pair A( size k). Originally, the 2D matrix is all 0 wh... 阅读全文

posted @ 2015-07-28 19:24 Eason Liu 阅读(3205) 评论(0) 推荐(0)

[LeetCode] Different Ways to Add Parentheses
摘要:Different Ways to Add ParenthesesGiven a string of numbers and operators, return all possible results from computing all the different possible ways t... 阅读全文

posted @ 2015-07-27 22:50 Eason Liu 阅读(4033) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 ··· 14 下一页