- 博客(28)
- 收藏
- 关注
原创 16. 3Sum Closest【M】【14】
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact
2016-05-31 15:56:50 383
原创 15. 3Sum【M】【28】
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c
2016-05-31 14:25:05 475
原创 341. Flatten Nested List Iterator【M】【42】
Given a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list -- whose elements may also be integers or other lists.Example 1:Given the list [
2016-05-31 13:26:27 607
原创 309. Best Time to Buy and Sell Stock with Cooldown【M】【56】
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one
2016-05-30 16:05:13 429
原创 10. Regular Expression Matching【H】【87】【vip】【再来一遍】
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st
2016-05-28 16:10:58 422
原创 304. Range Sum Query 2D - Immutable 【M】【27】
Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).The above rectangle (with the red bord
2016-05-28 13:26:54 406
原创 211. Add and Search Word - Data structure design【M】【91】
Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word or a regular expression string containing only let
2016-05-27 20:37:17 355
原创 208. Implement Trie (Prefix Tree)【58】【M】
Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z.Subscribe to see which companies asked this
2016-05-27 16:06:59 268
原创 133. Clone Graph【M】【73】【图的遍历】【再来一遍】【vip】
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each
2016-05-27 12:33:09 447
原创 310. Minimum Height Trees【M】【37】
For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called mini
2016-05-27 09:27:20 470
原创 210. Course Schedule II【M】【7】
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as
2016-05-26 13:41:43 555
原创 207. Course Schedule My SubmissionsQuestionEditorial Solution【M】【48】【vip】【再来一遍】
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a
2016-05-26 13:30:45 376
原创 350. Intersection of Two Arrays II【E】
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note:Each element in the result should appear as ma
2016-05-22 17:11:57 790
原创 233. Number of Digit One【H】【33】【再来一遍】
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, because digit 1 occurred in the followin
2016-05-21 16:46:28 501
原创 43. Multiply Strings 【66】【M】
Given two numbers represented as strings, return multiplication of the numbers as a string.Note:The numbers can be arbitrarily large and are non-negative.Converting the input string to integ
2016-05-18 20:25:50 508
原创 324. Wiggle Sort II【M】【33】
Given an unsorted array nums, reorder it such that nums[0] nums[2] .Example:(1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1, 5, 1, 6]. (2) Given nums = [1, 3, 2, 2,
2016-05-18 20:24:35 311
原创 349. Intersection of Two Arrays【E】
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.The res
2016-05-18 18:54:41 318
原创 150. Evaluate Reverse Polish Notation【M】【19】
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1",
2016-05-17 13:02:43 399
原创 229. Majority Element II 【M】【52】
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.Hint:How many majority elements could it po
2016-05-15 15:28:01 319
原创 164. Maximum Gap【H】【80】【桶排序】【VIP】
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 if the array contains less than 2 elements
2016-05-13 21:55:49 628
原创 60. Permutation Sequence 【M】【12】
The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""312
2016-05-13 20:33:30 299
原创 31 Next Permutations【M】【19】
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible
2016-05-13 19:02:39 280
原创 47. Permutations II 【M】【61】
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].
2016-05-13 15:42:53 279
原创 209. Minimum Size Subarray Sum 【M】【35】
Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead.For example, given the array [2,3
2016-05-11 21:12:46 743
原创 337. House Robber III 【M】【vip】
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour
2016-05-11 20:43:18 412
原创 187. Repeated DNA Sequences 【M】【30】
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 identify repeated sequences within the DNA.Wri
2016-05-09 16:44:01 528
原创 72. Edit Distance【H】【65】
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:
2016-05-09 16:24:52 641
原创 347. Top K Frequent Elements【M】【VIP】【字典排序】
Given a non-empty array of integers, return the k most frequent elements.For example,Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number
2016-05-09 14:58:23 456
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人