leetcode
文章平均质量分 69
doreenore
北京邮电大学
展开
-
罗马数字转换成整数
leetcode Problem 13: Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.题目:将罗马数字转换成整数 首先要了解罗马数字表示法,基本字符有7个:I,V,X,L,C,D,M,分别表示1,5,原创 2016-07-13 16:05:34 · 308 阅读 · 0 评论 -
Factorial Trailing Zeroes
题目:Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.乍一看,这确实不难,很简单的做法是先求n!嘛,然后求0的个数。结果是没问题,但是时间复杂度不符合要求,求n!就要O原创 2016-08-26 23:45:03 · 373 阅读 · 0 评论 -
Majority element
题目:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority e原创 2016-08-25 23:15:32 · 334 阅读 · 0 评论 -
Pascal's Triangle帕斯卡三角形算法
题目 Pascal's triangle Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]转载 2016-08-19 11:19:37 · 3375 阅读 · 0 评论 -
leetcode198-House Robber
题目:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacen转载 2016-08-29 00:26:06 · 363 阅读 · 0 评论 -
Reverse Bits
题目:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00原创 2016-08-27 22:55:50 · 386 阅读 · 0 评论 -
Reverse Integer
题目:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Test cases had been added to test the overflow behavior.本题很简单,唯一值得注意的点是反转之后要做溢出检查,有两种方式,一可以每原创 2016-08-27 15:48:51 · 381 阅读 · 0 评论 -
字符串匹配
leetcode 28:Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.本题属于字符串匹配问题,用KMP算法KMP算法:举例来说,有一个字符串"BBC ABCDAB ABCDABCDABDE",我想知道,里原创 2016-07-20 17:05:30 · 1139 阅读 · 0 评论 -
Next Permutation
下一个字典序 Next Permutationleetcode 31题目描述:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must原创 2017-03-07 20:43:03 · 334 阅读 · 0 评论