
Hard
文章平均质量分 78
BigFatSheep
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
642. Design Search Autocomplete System
问题描述Design a search autocomplete system for a search engine. Users may input a sentence (at least one word and end with a special character ‘#’). For each character they type except ‘#’, you need to ...原创 2018-11-20 03:58:13 · 718 阅读 · 0 评论 -
68. Text Justification
DescriptionGiven an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.You should pack your words in a g...原创 2018-11-10 02:35:57 · 187 阅读 · 0 评论 -
336. Palindrome Pairs
DescriptionGiven a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.Example 1:...原创 2018-11-10 02:24:29 · 196 阅读 · 0 评论 -
57. Insert Interval
DescriptionGiven a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start ti...原创 2018-11-10 02:11:25 · 151 阅读 · 0 评论 -
65. Valid Number
DescriptionValidate if a given string can be interpreted as a decimal number.Some examples:“0” => true" 0.1 " => true“abc” => false“1 a” => false“2e10” => true" -90e3 " => ...原创 2018-11-02 05:46:29 · 166 阅读 · 0 评论 -
97. Interleaving String
DescriptionGiven s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.Example 1:Input: s1 = “aabcc”, s2 = “dbbca”, s3 = “aadbbcbcac”Output: trueExample 2:Input: s1 = “aabcc”, s...原创 2018-10-28 02:16:20 · 136 阅读 · 0 评论 -
84. Largest Rectangle in Histogram
DescriptionGiven n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where widt...原创 2018-10-28 01:57:08 · 176 阅读 · 0 评论 -
76. Minimum Window Substring
DescriptionGiven a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).Example:Input: S = “ADOBECODEBANC”, T = “ABC”Output: “BANC”N...原创 2018-10-28 01:39:30 · 171 阅读 · 0 评论 -
85. Maximal Rectangle
DescriptionGiven a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.Example:Input:[[“1”,“0”,“1”,“0”,“0”],[“1”,“0”,“1”,“1”,“1”],[“1”,“...原创 2018-11-01 08:23:16 · 183 阅读 · 0 评论 -
51. N-Queens
DescriptionThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puz...原创 2018-10-27 05:55:25 · 151 阅读 · 0 评论 -
45. Jump Game II
DescriptionGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your ...原创 2018-10-27 05:20:00 · 130 阅读 · 0 评论 -
857. Minimum Cost to Hire K Workers
DescriptionThere are N workers. The i-th worker has a quality[i] and a minimum wage expectation wage[i].Now we want to hire exactly K workers to form a paid group. When hiring a group of K workers...原创 2018-11-02 13:57:51 · 240 阅读 · 0 评论 -
843. Guess the Word
DescriptionThis problem is an interactive problem new to the LeetCode platform.We are given a word list of unique words, each word is 6 letters long, and one word in this list is chosen as secret.Y...原创 2018-11-02 14:43:58 · 575 阅读 · 0 评论 -
829. Consecutive Numbers Sum
DescriptionGiven a positive integer N, how many ways can we write it as a sum of consecutive positive integers?Example 1:Input: 5Output: 2Explanation: 5 = 5 = 2 + 3Example 2:Input: 9Output: 3...原创 2018-11-10 03:52:44 · 209 阅读 · 0 评论 -
834. Sum of Distances in Tree
DescriptionAn undirected, connected tree with N nodes labelled 0…N-1 and N-1 edges are given.The ith edge connects nodes edges[i][0] and edges[i][1] together.Return a list ans, where ans[i] is the ...原创 2018-11-22 12:23:07 · 256 阅读 · 0 评论 -
815. Bus Routes
DescriptionWe have a list of bus routes. Each routes[i] is a bus route that the i-th bus repeats forever. For example if routes[0] = [1, 5, 7], this means that the first bus (0-th indexed) travels in...原创 2018-11-22 03:39:57 · 262 阅读 · 0 评论 -
340. Longest Substring with At Most K Distinct Characters
DescriptionGiven a string, find the length of the longest substring T that contains at most k distinct characters.Example 1:Input: s = “eceba”, k = 2Output: 3Explanation: T is “ece” which its len...原创 2018-11-19 03:16:04 · 252 阅读 · 0 评论 -
887. Super Egg Drop
DescriptionYou are given K eggs, and you have access to a building with N floors from 1 to N.Each egg is identical in function, and if an egg breaks, you cannot drop it again.You know that there ex...原创 2018-11-11 08:22:10 · 255 阅读 · 0 评论 -
403. Frog Jump
DescriptionA frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.Given ...原创 2018-11-11 05:59:03 · 409 阅读 · 0 评论 -
308. Range Sum Query 2D - Mutable
DescriptionGiven 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).Range Sum Query 2DThe above ...原创 2018-11-05 04:52:37 · 272 阅读 · 0 评论 -
803. Bricks Falling When Hit
DescriptionWe have a grid of 1s and 0s; the 1s in a cell represent bricks. A brick will not drop if and only if it is directly connected to the top of the grid, or at least one of its (4-way) adjace...原创 2018-11-05 04:49:36 · 308 阅读 · 0 评论 -
489. Robot Room Cleaner
DescriptionGiven a robot cleaner in a room modeled as a grid.Each cell in the grid can be empty or blocked.The robot cleaner with 4 given APIs can move forward, turn left or turn right. Each turn i...原创 2018-11-05 04:46:27 · 679 阅读 · 0 评论 -
37. Sudoku Solver
DescriptionWrite a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisfy all of the following rules:Each of the digits 1-9 must occur exactly once in each row....原创 2018-11-07 08:13:34 · 172 阅读 · 0 评论 -
44. Wildcard Matching
DescriptionGiven an input string (s) and a pattern §, implement wildcard pattern matching with support for ‘?’ and ‘*’.‘?’ Matches any single character.‘*’ Matches any sequence of characters (inclu...原创 2018-11-07 07:25:48 · 170 阅读 · 0 评论 -
128. Longest Consecutive Sequence
DescriptionGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.Example:Input: [100, 4, 200, 1, 3, 2]Outp...原创 2018-10-31 13:51:46 · 154 阅读 · 0 评论 -
25. Reverse Nodes in k-Group(need constant approach)
DescriptionGiven a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list. If the...原创 2018-10-31 11:48:45 · 189 阅读 · 0 评论 -
159. Longest Substring with At Most Two Distinct Characters
DescriptionGiven a string s , find the length of the longest substring t that contains at most 2 distinct characters.Example 1:Input: “eceba”Output: 3Explanation: t is “ece” which its length is ...原创 2018-10-31 11:42:18 · 200 阅读 · 0 评论 -
564. Find the Closest Palindrome
DescriptionGiven an integer n, find the closest integer (not including itself), which is a palindrome.The ‘closest’ is defined as absolute difference minimized between two integers.Example 1:Input...原创 2018-10-20 07:09:23 · 181 阅读 · 0 评论 -
72. Edit Distance
DescriptionGiven two words word1 and word2, find the minimum number of operations required to convert word1 to word2.You have the following 3 operations permitted on a word:Insert a characterDelet...原创 2018-10-20 06:36:13 · 167 阅读 · 0 评论 -
692. Top K Frequent Words
DescriptionGiven a non-empty list of words, return the k most frequent elements.Your answer should be sorted by frequency from highest to lowest. If two words have the same frequency, then the word ...原创 2018-10-17 12:48:26 · 161 阅读 · 0 评论 -
146. LRU Cache
DescriptionDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.get(key) - Get the value (will always be positive) of th...原创 2018-10-17 11:19:10 · 146 阅读 · 0 评论 -
301. Remove Invalid Parentheses
DescriptionRemove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may contain letters other than the parentheses...原创 2018-10-22 10:57:28 · 169 阅读 · 0 评论 -
273. Integer to English Words
DescriptionConvert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.Example 1:Input: 123Output: “One Hundred Twenty Three”Example 2:...原创 2018-10-16 08:17:50 · 235 阅读 · 0 评论 -
23. Merge k Sorted Lists
DescriptionMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[1->4->5,1->3->4,2->6]Output: 1->1->2->3-&g...原创 2018-10-16 05:57:15 · 126 阅读 · 0 评论 -
185. Department Top Three Salaries
问题描述The Employee table holds all employees. Every employee has an Id, and there is also a column for the department Id.+—-+——-+——–+————–+ | Id | Name | Salary | DepartmentId | +—-+——-+——–+————–...原创 2018-08-11 21:01:45 · 186 阅读 · 0 评论 -
41. First Missing Positive
问题描述Given an unsorted integer array, find the smallest missing positive integer.Example 1: Input: [1,2,0] Output: 3Example 2: Input: [3,4,-1,1] Output: 2Example 3: Input: [...原创 2018-05-26 14:18:15 · 155 阅读 · 0 评论 -
12. Integer to Roman
问题描述Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.题目链接:思路分析给一个1-3999的整数,将其转化为罗马数字的字符串。用一个极为丑陋的方式解决,将满足不同的条件的if语句放入循环中,每次减去相应的数值,直到num变为0;代码cl原创 2018-03-14 05:33:09 · 196 阅读 · 0 评论 -
124. Binary Tree Maximum Path Sum
DescriptionGiven a non-empty binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-chil...原创 2018-10-20 07:25:33 · 289 阅读 · 0 评论 -
295. Find Median from Data Stream
DescriptionMedian is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.For example,[2,3,4], t...原创 2018-10-23 04:09:52 · 305 阅读 · 0 评论 -
99. Recover Binary Search Tree
DescriptionTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Example 1:Input: [1,3,null,null,2]1/32Output: [3,1,null,null,2]3...原创 2018-10-28 06:01:45 · 167 阅读 · 0 评论