随笔分类 -  leetcode

上一页 1 2 3 4 5 6 7 下一页

[leetcode]Pow(x, n)
摘要:Pow(x, n)Implement pow(x,n).算法思路:二分法,没什么好说的,小心点就行;这个题时间比较苛刻。return pow(x,n >> 1) * pow(x,n >> 1) 是过不去的,因此把pow(x,n / 2)求出来先。其实时间复杂度而言,是一样的。【注意】:n的取值范围;... 阅读全文

posted @ 2014-07-25 23:31 喵星人与汪星人 阅读(172) 评论(0) 推荐(0) 编辑

[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 @ 2014-07-25 22:57 喵星人与汪星人 阅读(254) 评论(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 @ 2014-07-25 22:40 喵星人与汪星人 阅读(236) 评论(0) 推荐(0) 编辑

[leetcode]Insert Interval
摘要:Insert IntervalGiven a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals... 阅读全文

posted @ 2014-07-25 22:16 喵星人与汪星人 阅读(172) 评论(0) 推荐(0) 编辑

[leetcode]Merge Intervals
摘要:Merge IntervalsGiven a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18]... 阅读全文

posted @ 2014-07-25 20:56 喵星人与汪星人 阅读(193) 评论(0) 推荐(0) 编辑

[leetcode]Valid Palindrome
摘要:Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a pla... 阅读全文

posted @ 2014-07-25 15:47 喵星人与汪星人 阅读(164) 评论(0) 推荐(0) 编辑

[leetcode]Merge Sorted Array
摘要:Merge Sorted ArrayGiven two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that i... 阅读全文

posted @ 2014-07-24 22:52 喵星人与汪星人 阅读(221) 评论(0) 推荐(0) 编辑

[leetcode]Length of Last Word
摘要:Length of Last WordGiven a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.I... 阅读全文

posted @ 2014-07-24 22:24 喵星人与汪星人 阅读(132) 评论(0) 推荐(0) 编辑

[leetcode]Simplify Path
摘要:Simplify PathGiven an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to sh... 阅读全文

posted @ 2014-07-24 22:03 喵星人与汪星人 阅读(235) 评论(0) 推荐(1) 编辑

[leetcode]Add Binary
摘要:Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".算法思路:模拟二进制加法,跟十进制木有区别,将a,b转置(不转置的话,倒着... 阅读全文

posted @ 2014-07-24 21:08 喵星人与汪星人 阅读(310) 评论(0) 推荐(0) 编辑

[leetcode]Substring with Concatenation of All Words
摘要:Substring with Concatenation of All WordsYou are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices o... 阅读全文

posted @ 2014-07-24 17:28 喵星人与汪星人 阅读(203) 评论(0) 推荐(0) 编辑

[leetcode]Valid Parentheses
摘要:Valid ParenthesesGiven a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must clos... 阅读全文

posted @ 2014-07-24 16:00 喵星人与汪星人 阅读(148) 评论(0) 推荐(0) 编辑

[leetcode]Reverse Words in a String
摘要:Reverse Words in a StringGiven an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click... 阅读全文

posted @ 2014-07-24 00:26 喵星人与汪星人 阅读(160) 评论(0) 推荐(0) 编辑

[leetcode]ZigZag Conversion
摘要:ZigZag ConversionThe string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern i... 阅读全文

posted @ 2014-07-23 23:40 喵星人与汪星人 阅读(157) 评论(0) 推荐(0) 编辑

[leetcode]Gray Code
摘要:Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the tot... 阅读全文

posted @ 2014-07-23 22:16 喵星人与汪星人 阅读(274) 评论(0) 推荐(0) 编辑

[leetcode]Permutation Sequence
摘要:Permutation SequenceThe set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the fo... 阅读全文

posted @ 2014-07-23 20:32 喵星人与汪星人 阅读(329) 评论(0) 推荐(0) 编辑

[leetcode]Next Permutation
摘要:Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangemen... 阅读全文

posted @ 2014-07-23 18:41 喵星人与汪星人 阅读(262) 评论(0) 推荐(0) 编辑

[leetcode]PermutationsII
摘要:Permutations IIGiven a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2]have the follow... 阅读全文

posted @ 2014-07-23 17:25 喵星人与汪星人 阅读(287) 评论(0) 推荐(0) 编辑

[leetcode]Add Two Numbers
摘要:Add Two NumbersYou are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes co... 阅读全文

posted @ 2014-07-23 16:17 喵星人与汪星人 阅读(240) 评论(0) 推荐(0) 编辑

[leetcode]Combinations
摘要:CombinationsGiven two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3... 阅读全文

posted @ 2014-07-22 15:40 喵星人与汪星人 阅读(277) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 下一页