- 博客(355)
- 收藏
- 关注
原创 773. Sliding Puzzle
On a 2x3 board, there are 5 tiles represented by the integers 1 through 5, and an empty square represented by 0.A move consists of choosing 0 and a 4-directionally adjacent number and swapping it.The ...
2018-06-05 09:16:33
415
原创 778. Swim in Rising Water
On an N x N grid, each square grid[i][j] represents the elevation at that point (i,j).Now rain starts to fall. At time t, the depth of the water everywhere is t. You can swim from a square to another ...
2018-06-03 16:44:05
380
原创 792. Number of Matching Subsequences
Given string S and a dictionary of words words, find the number of words[i] that is a subsequence of S.Example :Input: S = "abcde"words = ["a", "bb", "acd", "ace"]Output: 3Explanation: There are ...
2018-05-31 15:06:38
247
原创 743. Network Delay Time
There are N network nodes, labelled 1 to N.Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, v is the target node, and w is the time it takes for ...
2018-05-28 11:34:39
192
原创 752. Open the Lock
You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely and wrap around: for example we can turn...
2018-05-23 17:03:37
307
原创 355. Design Twitter
Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the user's news feed. Your design should support the fo
2018-01-22 16:59:28
255
原创 399. Evaluate Division
Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answ
2018-01-22 15:47:08
162
原创 394. Decode String
Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactlyk times. Note that k is gu
2018-01-21 11:04:42
236
原创 396. Rotate Function
Given an array of integers A and let n to be its length.Assume Bk to be an array obtained by rotating the arrayA k positions clock-wise, we define a "rotation function" F on A as follow:F(k) =
2018-01-21 09:08:40
164
原创 746. Prefix and Suffix Search
Given many words, words[i] has weight i.Design a class WordFilter that supports one function, WordFilter.f(String prefix, String suffix).It will return the word with givenprefix and suffix with ma
2017-12-31 11:06:54
343
原创 736. Parse Lisp Expression
You are given a string expression representing a Lisp-like expression to return the integer value of.The syntax for these expressions is given as follows.An expression is either an integer, a le
2017-12-31 09:53:21
333
原创 675. Cut Off Trees for Golf Event
You are asked to cut off trees in a forest for a golf event. The forest is represented as a non-negative 2D map, in this map:0 represents the obstacle can't be reached.1 represents the ground ca
2017-12-25 15:23:00
224
原创 667. Beautiful Arrangement II
Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n and obeys the following requirement: Suppose this list is [a1, a2, a3,
2017-12-25 13:44:49
241
原创 661. Image Smoother
Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes the average gray scale (rounding down) of all the 8 surro
2017-12-22 15:17:59
199
原创 649. Dota2 Senate
In the world of Dota2, there are two parties: the Radiant and the Dire.The Dota2 senate consists of senators coming from two parties. Now the senate wants to make a decision about a change in the
2017-12-22 12:22:24
346
原创 739. Daily Temperatures
Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this
2017-12-13 17:12:12
1107
原创 740. Delete and Earn
Given an array nums of integers, you can perform operations on the array.In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every element equal to
2017-12-13 16:24:47
559
原创 732. My Calendar III
Implement a MyCalendarThree class to store your events. A new event can always be added.Your class will have one method, book(int start, int end). Formally, this represents a booking on the half
2017-12-06 15:26:33
326
原创 729. My Calendar I
Implement a MyCalendar class to store your events. A new event can be added if adding the event will not cause a double booking.Your class will have the method, book(int start, int end). Formall
2017-11-30 16:51:31
171
原创 676. Implement Magic Dictionary
Implement a magic directory with buildDict, and search methods.For the method buildDict, you'll be given a list of non-repetitive words to build a dictionary.For the method search, you'll be g
2017-11-24 11:17:10
248
原创 725. Split Linked List in Parts
Given a (singly) linked list with head node root, write a function to split the linked list into k consecutive linked list "parts".The length of each part should be as equal as possible: no two pa
2017-11-22 17:40:01
205
原创 677. Map Sum Pairs
Implement a MapSum class with insert, and sum methods.For the method insert, you'll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the
2017-11-15 17:36:43
314
原创 718. Maximum Length of Repeated Subarray
Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.Example 1:Input:A: [1,2,3,2,1]B: [3,2,1,4,7]Output: 3Explanation: The repeated subar
2017-11-15 16:12:13
195
原创 17. Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string
2017-10-26 21:26:56
142
原创 47. Permutations II
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], [2,1,1
2017-10-26 20:58:20
120
原创 46. Permutations
Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]
2017-10-26 20:29:39
123
原创 680. Valid Palindrome II
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.Example 1:Input: "aba"Output: TrueExample 2:Input: "abca"Output: TrueExplan
2017-09-28 15:54:23
178
原创 299. Bulls and Cows
You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint t
2017-09-21 16:54:48
175
原创 289. Game of Life
According to the Wikipedia's article: "The Game of Life, also known simply asLife, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given a board with m b
2017-09-15 10:14:44
173
原创 172. Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.Credits:Special thanks to @ts for adding this problem and creating a
2017-09-14 16:53:10
148
原创 168. Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB Credits:S
2017-09-14 16:35:37
230
原创 119. Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algorithm to use only O(k) extra space?
2017-09-14 11:27:55
221
原创 236. Lowest Common Ancestor of a Binary Tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two node
2017-09-12 17:36:38
156
原创 187. Repeated DNA Sequences
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.Write
2017-09-12 00:12:53
211
原创 557. Reverse Words in a String III
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode contest"
2017-07-20 14:37:28
228
原创 215. Kth Largest Element in an Array
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, return 5.
2017-07-11 00:52:42
294
原创 223. Rectangle Area
Find the total area covered by two rectilinear rectangles in a2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that the total
2017-07-09 23:34:23
223
原创 88. Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 intonums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal tom + n) to hold addit
2017-07-09 22:56:32
136
原创 633. Sum of Square Numbers
Given a non-negative integer c, your task is to decide whether there’re two integers a and b such that a2 + b2 = c.Example 1:Input: 5 Output: True Explanation: 1 * 1 + 2 * 2 = 5Example 2:Input: 3 Ou
2017-07-09 13:48:47
439
原创 227. Basic Calculator II
Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should trunca
2017-07-09 11:57:14
220
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人