随笔分类 -  Leetcode

1 2 3 4 5 ··· 8 下一页
摘要:You are playing the followingBulls and Cowsgame with your friend: You write a 4-digit secret number and ask your friend to guess it. Each time your fr... 阅读全文
posted @ 2015-11-03 08:53 Phoebe815 阅读(268) 评论(0) 推荐(0)
摘要:Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Return 6... 阅读全文
posted @ 2015-11-03 06:56 Phoebe815 阅读(178) 评论(0) 推荐(0)
摘要:Implement a basic calculator to evaluate a simple expression string.The expression string contains onlynon-negativeintegers,+,-,*,/operators and empty... 阅读全文
posted @ 2015-10-31 09:55 Phoebe815 阅读(127) 评论(0) 推荐(0)
摘要:Given an array of integers, find out whether there are two distinct indicesiandjin the array such that the difference betweennums[i]andnums[j]is at mo... 阅读全文
posted @ 2015-10-31 04:26 Phoebe815 阅读(155) 评论(0) 推荐(0)
摘要:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to ... 阅读全文
posted @ 2015-10-22 19:41 Phoebe815 阅读(155) 评论(0) 推荐(0)
摘要:There are a total ofncourses you have to take, labeled from0ton - 1.Some courses may have prerequisites, for example to take course 0 you have to firs... 阅读全文
posted @ 2015-10-22 09:39 Phoebe815 阅读(171) 评论(0) 推荐(0)
摘要:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.------------------------题是比较简单,但是解法中用了static... 阅读全文
posted @ 2015-09-20 13:21 Phoebe815 阅读(165) 评论(0) 推荐(0)
摘要:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be ... 阅读全文
posted @ 2015-02-01 08:39 Phoebe815 阅读(183) 评论(0) 推荐(0)
摘要:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially... 阅读全文
posted @ 2015-02-01 02:17 Phoebe815 阅读(156) 评论(0) 推荐(0)
摘要:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord... 阅读全文
posted @ 2015-01-30 05:13 Phoebe815 阅读(145) 评论(0) 推荐(0)
摘要:A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message conta... 阅读全文
posted @ 2015-01-30 02:23 Phoebe815 阅读(144) 评论(0) 推荐(0)
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret... 阅读全文
posted @ 2015-01-26 04:54 Phoebe815 阅读(146) 评论(0) 推荐(0)
摘要:Table:Person+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName ... 阅读全文
posted @ 2015-01-15 08:02 Phoebe815 阅读(759) 评论(0) 推荐(0)
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl... 阅读全文
posted @ 2014-12-31 07:42 Phoebe815 阅读(199) 评论(0) 推荐(0)
摘要:Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 ... 阅读全文
posted @ 2014-12-31 05:47 Phoebe815 阅读(268) 评论(0) 推荐(0)
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes... 阅读全文
posted @ 2014-12-30 02:40 Phoebe815 阅读(110) 评论(0) 推荐(0)
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be on... 阅读全文
posted @ 2014-12-02 14:03 Phoebe815 阅读(221) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文
posted @ 2014-12-02 12:06 Phoebe815 阅读(119) 评论(0) 推荐(0)
摘要:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ... 阅读全文
posted @ 2014-12-02 07:18 Phoebe815 阅读(182) 评论(0) 推荐(0)
摘要:Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm should ru... 阅读全文
posted @ 2014-12-01 17:16 Phoebe815 阅读(144) 评论(0) 推荐(0)

1 2 3 4 5 ··· 8 下一页