- 博客(234)
- 收藏
- 关注
原创 592. Fraction Addition and Subtraction
592. Fraction Addition and Subtraction
2022-07-27 22:15:01
288
原创 871. Minimum Number of Refueling Stops
871. Minimum Number of Refueling Stops
2022-07-03 17:54:33
183
原创 2290. Minimum Obstacle Removal to Reach Corner
题目:You are given a0-indexed2D integer arraygridof sizem x n. Each cell has one of two values:0represents anemptycell, 1represents anobstaclethat may be removed.You can move up, down, left, or right from and to an empty cell.Returnthemi...
2022-05-30 21:55:51
225
原创 106. Construct Binary Tree from Inorder and Postorder Traversal
题目:Given two integer arraysinorderandpostorderwhereinorderis the inorder traversal of a binary tree andpostorderis the postorder traversal of the same tree, construct and returnthe binary tree.Example 1:Input: inorder = [9,3,15,20,7], p...
2022-05-06 21:15:25
200
原创 713. Subarray Product Less Than K
题目:Given an array of integersnumsand an integerk, returnthe number of contiguous subarrays where the product of all the elements in the subarray is strictly less thank.Example 1:Input: nums = [10,5,2,6], k = 100Output: 8Explanation: The 8 s...
2022-05-05 22:33:58
267
原创 491. Increasing Subsequences
题目:Given an integer arraynums, return all the different possible increasing subsequences of the given array withat least two elements. You may return the answer inany order.The given array may contain duplicates, and two equal integers should also b...
2022-04-28 23:44:35
150
原创 93. Restore IP Addresses
题目:Avalid IP addressconsists of exactly four integers separated by single dots. Each integer is between0and255(inclusive) and cannot have leading zeros.For example,"0.1.2.201"and"192.168.1.1"arevalidIP addresses, but"0.011.255.245","192.1...
2022-04-28 23:06:02
210
原创 101. Symmetric Tree
题目:Given therootof a binary tree,check whether it is a mirror of itself(i.e., symmetric around its center).Example 1:Input: root = [1,2,2,3,4,4,3]Output: trueExample 2:Input: root = [1,2,2,null,3,null,3]Output: falseConstraint...
2022-04-21 23:25:34
153
原创 131. Palindrome Partitioning
题目:Given a strings, partitionssuch that every substring of the partition is apalindrome. Return all possible palindrome partitioning ofs.Apalindromestring is a string that reads the same backward as forward.Example 1:Input: s = "aab"Outp...
2022-04-18 23:36:15
136
原创 40. Combination Sum II
题目:Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations incandidateswhere the candidate numbers sum totarget.Each number incandidatesmay only be usedoncein the combination.Note:The so...
2022-04-18 23:31:01
120
原创 39. Combination Sum
题目:Given an array ofdistinctintegerscandidatesand a target integertarget, returna list of allunique combinationsofcandidateswhere the chosen numbers sum totarget.You may return the combinations inany order.Thesamenumber may be chosen fro...
2022-04-18 23:10:00
208
原创 72. Edit Distance
题目:Given two stringsword1andword2, returnthe minimum number of operations required to convertword1toword2.You have the following three operations permitted on a word:Insert a character Delete a character Replace a characterExample 1:In...
2022-04-17 22:33:48
318
原创 583. Delete Operation for Two Strings
题目:Given two stringsword1andword2, returnthe minimum number ofstepsrequired to makeword1andword2the same.In onestep, you can delete exactly one character in either string.Example 1:Input: word1 = "sea", word2 = "eat"Output: 2Explana...
2022-04-17 22:17:48
476
原创 819. Most Common Word
题目:Given a stringparagraphand a string array of the banned wordsbanned, returnthe most frequent word that is not banned. It isguaranteedthere isat least one wordthat is not banned, and that the answer isunique.The words inparagrapharecase-i...
2022-04-17 18:42:06
268
原创 380. Insert Delete GetRandom O(1)
题目:Implement theRandomizedSetclass:RandomizedSet()Initializes theRandomizedSetobject. bool insert(int val)Inserts an itemvalinto the set if not present. Returnstrueif the item was not present,falseotherwise. bool remove(int val)Removes a...
2022-04-13 21:34:23
187
原创 718. Maximum Length of Repeated Subarray
题目:Given two integer arraysnums1andnums2, returnthe maximum length of a subarray that appears inbotharrays.Example 1:Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7]Output: 3Explanation: The repeated subarray with maximum length is [3,2,1]....
2022-04-11 21:32:33
183
原创 213. House Robber II
题目:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place arearranged in a circle.That means the first house is the neighbor of the last one. Meanwhile, adjacent h..
2022-03-24 23:04:56
168
原创 198. House Robber
题目:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected andit will autom.
2022-03-24 23:00:19
383
原创 139. Word Break
题目:Given a stringsand a dictionary of stringswordDict, returntrueifscan be segmented into a space-separated sequence of one or more dictionary words.Notethat the same word in the dictionary may be reused multiple times in the segmentation.E...
2022-03-23 21:59:24
235
原创 2038. Remove Colored Pieces if Both Neighbors are the Same Color
题目:There arenpieces arranged in a line, and each piece is colored either by'A'or by'B'. You are given a stringcolorsof lengthnwherecolors[i]is the color of theithpiece.Alice and Bob are playing a game where they takealternating turnsremo...
2022-03-22 22:04:32
186
原创 377. Combination Sum IV
题目:Given an array ofdistinctintegersnumsand a target integertarget, returnthe number of possible combinations that add up totarget.The test cases are generated so that the answer can fit in a32-bitinteger.Example 1:Input: nums = [1,2,3]...
2022-03-21 22:03:09
270
原创 322. Coin Change
题目:You are given an integer arraycoinsrepresenting coins of different denominations and an integeramountrepresenting a total amount of money.Returnthe fewest number of coins that you need to make up that amount. If that amount of money cannot be m...
2022-03-21 21:50:49
225
原创 494. Target Sum
题目:You are given an integer arraynumsand an integertarget.You want to build anexpressionout of nums by adding one of the symbols'+'and'-'before each integer in nums and then concatenate all the integers.For example, ifnums = [2, 1], you can...
2022-03-16 22:24:36
382
原创 1049. Last Stone Weight II
题目:You are given an array of integersstoneswherestones[i]is the weight of theithstone.We are playing a game with the stones. On each turn, we choose any two stones and smash them together. Suppose the stones have weightsxandywithx <= y. T...
2022-03-14 23:12:47
522
原创 343. Integer Break
题目:Given an integern, break it into the sum ofkpositive integers, wherek >= 2, and maximize the product of those integers.Returnthe maximum product you can get.Example 1:Input: n = 2Output: 1Explanation: 2 = 1 + 1, 1 × 1 = 1.Example...
2022-03-09 21:37:13
328
原创 63. Unique Paths II
题目:A robot is located at the top-left corner of am x ngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in t..
2022-03-09 21:27:03
116
原创 2055. Plates Between Candles
题目:There is a long table with a line of plates and candles arranged on top of it. You are given a0-indexedstringsconsisting of characters'*'and'|'only, where a'*'represents aplateand a'|'represents acandle.You are also given a0-indexed...
2022-03-08 23:03:48
180
原创 746. Min Cost Climbing Stairs
题目:You are given an integer arraycostwherecost[i]is the cost ofithstep on a staircase. Once you pay the cost, you can either climb one or two steps.You can either start from the step with index0, or the step with index1.Returnthe minimum cos...
2022-03-07 21:37:45
166
原创 2100. Find Good Days to Rob the Bank
题目:You and a gang of thieves are planning on robbing a bank. You are given a0-indexedinteger arraysecurity, wheresecurity[i]is the number of guards on duty on theithday. The days are numbered starting from0. You are also given an integertime.T...
2022-03-06 15:10:42
100
原创 08.13. 堆箱子
题目:堆箱子。给你一堆n个箱子,箱子宽 wi、深 di、高 hi。箱子不能翻转,将箱子堆起来时,下面箱子的宽度、高度和深度必须大于上面的箱子。实现一种方法,搭出最高的一堆箱子。箱堆的高度为每个箱子高度的总和。输入使用数组[wi, di, hi]表示每个箱子。示例1:输入:box = [[1, 1, 1], [2, 2, 2], [3, 3, 3]]输出:6示例2:输入:box = [[1, 1, 1], [2, 3, 4], [2, 6, 7], [3, 4, 5]]输出:...
2022-03-05 19:00:20
590
原创 676. Implement Magic Dictionary
题目:Design a data structure that is initialized with a list ofdifferentwords. Provided a string, you should determine if you can change exactly one character in this string to match any word in the data structure.Implement theMagicDictionaryclass:...
2022-03-05 18:52:22
154
原创 211. Design Add and Search Words Data Structure
题目:Design a data structure that supports adding new words and finding if a string matches any previously added string.Implement theWordDictionaryclass:WordDictionary()Initializes the object. void addWord(word)Addswordto the data structure, it ...
2022-03-05 18:45:07
282
原创 17.17. 多次搜索
题目:给定一个较长字符串big和一个包含较短字符串的数组smalls,设计一个方法,根据smalls中的每一个较短字符串,对big进行搜索。输出smalls中的字符串在big里出现的所有位置positions,其中positions[i]为smalls[i]出现的所有位置。示例:输入:big = "mississippi"smalls = ["is","ppi","hi","sis","i","ssippi"]输出: [[1,4],[8],[],[3],[1,4,7,10],[5]]提示
2022-03-04 22:35:26
570
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人