
leetcode
景行cmy
这个作者很懒,什么都没留下…
展开
-
leetcode 1074. Number of Submatrices That Sum to Target
Given amatrix, and atarget, return the number of non-empty submatrices that sum totarget.A submatrixx1, y1, x2, y2is the set of all cellsmatrix[x][y]withx1 <= x <= x2andy1 <= y &l...原创 2019-11-05 17:35:00 · 248 阅读 · 0 评论 -
leetcode 928. Minimize Malware Spread II
(This problem is the same asMinimize Malware Spread, with the differences bolded.)In a network of nodes, each nodeiis directly connected to another nodejif and only ifgraph[i][j] = 1.Some no...原创 2019-11-05 16:00:09 · 313 阅读 · 0 评论 -
leetcode 568. Maximum Vacation Days
LeetCode wants to give one of its best employees the option to travel amongNcities to collect algorithm problems. But all work and no play makes Jack a dull boy, you could take vacations in some par...原创 2019-10-30 09:31:46 · 244 阅读 · 0 评论 -
124. Binary Tree Maximum Path Sum
Given anon-emptybinary 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-child connectio...原创 2019-03-26 11:23:27 · 86 阅读 · 0 评论 -
968. Binary Tree Cameras
Given a binary tree, we install cameras on the nodes of the tree.Each camera ata node can monitorits parent, itself, and its immediate children.Calculate the minimum number of cameras needed to...转载 2019-03-26 11:30:49 · 253 阅读 · 0 评论 -
145. Binary Tree Postorder Traversal
Given a binary tree, return thepostordertraversal of its nodes' values.Example:Input:[1,null,2,3] 1 \ 2 / 3Output:[3,2,1]Follow up:Recursive solution is trivial, coul...原创 2019-03-26 11:35:00 · 153 阅读 · 0 评论 -
99. Recover Binary Search Tree
Two 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 /3 \ 2Output: [3,1,null,nul...原创 2019-03-26 14:33:03 · 94 阅读 · 0 评论 -
834. Sum of Distances in Tree c++
An undirected, connectedtree withNnodes labelled0...N-1andN-1edgesaregiven.Theith edge connects nodesedges[i][0]andedges[i][1]together.Return a listans, whereans[i]is the sum of th...原创 2019-03-26 17:20:31 · 211 阅读 · 0 评论 -
297. Serialize and Deserialize Binary Tree c++ 层次遍历
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be...原创 2019-03-26 21:42:42 · 286 阅读 · 0 评论 -
leetcode 363. Max Sum of Rectangle No Larger Than K
Given a non-empty 2D matrixmatrixand an integerk, find the max sum of a rectangle in thematrixsuch that its sum is no larger thank.Example:Input: matrix = [[1,0,1],[0,-2,3]], k = 2Output: ...原创 2019-04-07 11:36:07 · 121 阅读 · 0 评论 -
leetcode 778. Swim in Rising Water
On an N x Ngrid, each squaregrid[i][j]represents the elevation at that point(i,j).Now rain starts to fall. At timet, the depth of the water everywhere ist. You can swim from a square to anothe...原创 2019-04-07 11:38:17 · 211 阅读 · 0 评论 -
leetcode 410. Split Array Largest Sum
Given an array which consists of non-negative integers and an integerm, you can split the array intomnon-empty continuous subarrays. Write an algorithm to minimize the largest sum among thesemsub...原创 2019-04-07 11:39:29 · 146 阅读 · 0 评论 -
leetcode 668. Kth Smallest Number in Multiplication Table
Nearly every one have used theMultiplication Table. But could you find out thek-thsmallest number quickly from the multiplication table?Given the heightmand the lengthnof am * nMultiplicatio...原创 2019-04-07 11:40:33 · 123 阅读 · 0 评论 -
leetcode 786. K-th Smallest Prime Fraction
A sorted listAcontains 1, plus some number of primes. Then, for every p < q in the list, we consider the fraction p/q.What is theK-th smallest fraction considered? Return your answer as an a...原创 2019-04-07 11:41:44 · 127 阅读 · 0 评论 -
leetcode 668 Kth Smallest Number in Multiplication Table C++
Nearly every one have used theMultiplication Table. But could you find out thek-thsmallest number quickly from the multiplication table?Given the heightmand the lengthnof am * nMultiplicatio...原创 2019-03-28 21:53:14 · 262 阅读 · 0 评论 -
leetcode 174. Dungeon Game c++
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially pos...原创 2019-04-11 20:24:30 · 150 阅读 · 0 评论 -
leetcode 719. Find K-th Smallest Pair Distance c++
Given an integer array, return the k-th smallestdistanceamong all the pairs. The distance of a pair (A, B) is defined as the absolute difference between A and B.Example 1:Input:nums = [1,3,1]...原创 2019-04-11 20:25:57 · 169 阅读 · 0 评论 -
leetcode 778. Swim in Rising Water
On an N x Ngrid, each squaregrid[i][j]represents the elevation at that point(i,j).Now rain starts to fall. At timet, the depth of the water everywhere ist. You can swim from a square to anothe...原创 2019-04-02 21:59:12 · 270 阅读 · 0 评论 -
leetcode 354. Russian Doll Envelopes
You have a number of envelopes with widths and heights given as a pair of integers(w, h). One envelope can fit into another if and only if both the width and height of one envelope is greater than th...原创 2019-04-08 21:52:04 · 194 阅读 · 0 评论 -
leetcode 483. Smallest Good Base
For an integer n, we call k>=2 agood baseof n, if all digits of n base k are 1.Now given a string representing n, you should return the smallest good base of n in string format.Example 1:I...原创 2019-04-08 21:54:00 · 148 阅读 · 0 评论 -
leetcode 878. Nth Magical Number
A positive integerismagicalif it is divisible by eitherAorB.Return theN-th magical number. Since the answer may be very large,return it modulo10^9 + 7.Example 1:Input: N = 1, A = 2...原创 2019-04-12 16:37:39 · 171 阅读 · 0 评论 -
leetcode 4. Median of Two Sorted Arrays
There are two sorted arraysnums1andnums2of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You may assumenums1andn...原创 2019-04-12 16:38:40 · 145 阅读 · 0 评论 -
leetcode 164 maximun gap
164.Maximum GapHard450124FavoriteShareGiven an unsorted array, find the maximum difference between the successive elements in its sorted form.Return 0 if the array contains less than 2 elemen...原创 2019-04-25 22:11:38 · 115 阅读 · 0 评论 -
leetcode 956
You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel support must be an equal height.You have a collectio...原创 2019-04-22 11:02:55 · 255 阅读 · 0 评论 -
leetcode 552. Student Attendance Record II
552.Student Attendance Record IIGiven a positive integern, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, r...原创 2019-04-22 11:04:02 · 155 阅读 · 0 评论 -
273. Integer to English Words c++
273.Integer to English WordsConvert 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 Twen...原创 2019-04-26 19:20:33 · 110 阅读 · 0 评论 -
leetcode 403. Frog Jump
403.Frog JumpHard47256FavoriteShareA 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 n...原创 2019-04-26 21:44:14 · 109 阅读 · 0 评论 -
leetcode 188 Best Time to Buy and Sell Stock IV
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at mostktransactions.Note:You may not eng...原创 2019-05-01 20:14:34 · 130 阅读 · 0 评论 -
leetcode 312 Burst Balloons c++
312.Burst BalloonsHard124534FavoriteShareGivennballoons, indexed from0ton-1. Each balloon is painted with a number on it represented by arraynums. You are asked to burst all the balloons....原创 2019-04-27 16:06:45 · 230 阅读 · 0 评论 -
leetcode 135 candy
There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one ca...原创 2019-04-27 18:51:37 · 123 阅读 · 0 评论 -
leetcode 123. Best Time to Buy and Sell Stock III
123.Best Time to Buy and Sell Stock IIIHard98953FavoriteShareSay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum pro...原创 2019-04-27 20:47:46 · 165 阅读 · 0 评论 -
leetcode 472. Concatenated Words
Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words.A concatenated word is defined as a string that is comprised entirel...原创 2019-05-02 20:45:58 · 247 阅读 · 0 评论 -
leetcode 466. Count The Repetitions
466.Count The RepetitionsHard10279FavoriteShareDefineS = [s,n]as the string S which consists of n connected strings s. For example,["abc", 3]="abcabcabc".On the other hand, we define that...原创 2019-05-03 10:34:40 · 395 阅读 · 0 评论 -
leetcode 115. Distinct Subsequences
Given a stringSand a stringT, count the number of distinct subsequences ofSwhich equalsT.A subsequence of a string is a new string which is formed from the original string by deleting some (ca...原创 2019-05-03 19:20:15 · 90 阅读 · 0 评论 -
leetcode 97. Interleaving String c++
97.Interleaving StringHard72735FavoriteShareGivens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.Example 1:Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"Outp...原创 2019-05-06 18:50:45 · 178 阅读 · 0 评论 -
leetcode 72 Edit Distance c++
72.Edit DistanceHard197930FavoriteShareGiven two wordsword1andword2, find the minimum number of operations required to convertword1toword2.You have the following 3 operations permitted ...原创 2019-05-06 19:01:31 · 158 阅读 · 0 评论 -
212. Word Search II
212.Word Search IIHard107368FavoriteShareGiven a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjac...原创 2019-05-22 16:32:37 · 258 阅读 · 0 评论 -
leetcode 514 Freedom Trail
In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring", and use the dial to spell a specific keyword in order to open the door....原创 2019-07-09 16:27:23 · 216 阅读 · 0 评论 -
leetcode 126. Word Ladder II
Given two words (beginWordandendWord), and a dictionary's word list, find all shortest transformation sequence(s) frombeginWordtoendWord, such that:Only one letter can be changed at a time Eac...原创 2019-07-14 14:24:34 · 134 阅读 · 0 评论 -
leetcode 407 Trapping Rain Water II
Given anm x nmatrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.Note:Bothmandnare le...转载 2019-07-14 17:08:02 · 133 阅读 · 0 评论