![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode每日一题202012
Bryan要加油
这个作者很懒,什么都没留下…
展开
-
435. Non-overlapping Intervals(Leetcode每日一题-2020.12.31)--抄答案
ProblemGiven a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.Note:You may assume the interval’s end point is always bigger than its start point.Intervals like [1,2] a原创 2020-12-31 10:37:46 · 119 阅读 · 0 评论 -
1046. Last Stone Weight(Leetcode每日一题-2020.12.30)
ProblemWe have a collection of stones, each stone has a positive integer weight.Each turn, we choose the two heaviest stones and smash them together. Suppose the stones have weights x and y with x <= y. The result of this smash is:If x == y, both原创 2020-12-30 21:14:57 · 102 阅读 · 0 评论 -
330. Patching Array(Leetcode每日一题-2020.12.29)--抄答案
ProblemGiven a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some elements in the array. Return the minimum number of patches required.Examp原创 2020-12-29 21:26:01 · 128 阅读 · 0 评论 -
188. Best Time to Buy and Sell Stock IV(Leetcode每日一题-2020.12.28)--抄答案
ProblemYou are given an integer array prices where prices[i] is the price of a given stock on the ith day.Design an algorithm to find the maximum profit. You may complete at most k transactions.Notice that you may not engage in multiple transactions sim原创 2020-12-28 21:49:07 · 202 阅读 · 0 评论 -
205. Isomorphic Strings(Leetcode每日一题-2020.12.27)
ProblemGiven two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another character while preserving the order of characters原创 2020-12-28 21:03:21 · 126 阅读 · 0 评论 -
85. Maximal Rectangle(Leetcode每日一题-2020.12.26)--抄答案
ProblemGiven a rows x cols binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.Constraints:rows == matrix.lengthcols == matrix.length0 <= row, cols <= 200matrix[i][j] is ‘0’ or ‘1’Example原创 2020-12-26 21:42:42 · 154 阅读 · 0 评论 -
455. Assign Cookies(Leetcode每日一题-2020.12.25)--抄答案
ProblemAssume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and e原创 2020-12-26 21:39:54 · 138 阅读 · 0 评论 -
135. Candy(Leetcode每日一题-2020.12.24)--抄答案
ProblemThere are N children 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 candy.Children with a higher rating get more candie原创 2020-12-24 20:49:14 · 243 阅读 · 0 评论 -
387. First Unique Character in a String(Leetcode每日一题-2020.12.23)
ProblemGiven a string, find the first non-repeating character in it and return its index. If it doesn’t exist, return -1.Note: You may assume the string contains only lowercase English letters.Examples = “leetcode”return 0.s = “loveleetcode”return原创 2020-12-23 21:12:14 · 122 阅读 · 0 评论 -
103. Binary Tree Zigzag Level Order Traversal(Leetcode每日一题-2020.12.22)
ProblemGiven a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tree [3,9,20,null,null,15,7],return its zigzag lev原创 2020-12-22 20:39:34 · 112 阅读 · 0 评论 -
746. Min Cost Climbing Stairs(Leetcode每日一题-2020.12.21)
ProblemOn a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the step原创 2020-12-21 21:22:36 · 144 阅读 · 1 评论 -
316. Remove Duplicate Letters(Leetcode每日一题-2020.12.20)--抄答案
ProblemGiven a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.Constraints:1 <= s.length <= 104s consists of l原创 2020-12-20 21:18:39 · 224 阅读 · 0 评论 -
48. Rotate Image(Leetcode每日一题-2020.12.19)
ProblemYou are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rot原创 2020-12-19 11:04:38 · 166 阅读 · 1 评论 -
389. Find the Difference(Leetcode每日一题-2020.12.18)
ProblemYou are given two strings s and t.String t is generated by random shuffling string s and then add one more letter at a random position.Return the letter that was added to t.Constraints:0 <= s.length <= 1000t.length == s.length + 1s and原创 2020-12-18 20:07:44 · 214 阅读 · 1 评论 -
714. Best Time to Buy and Sell Stock with Transaction Fee(Leetcode每日一题-2020.12.17)
ProblemYour are given an array of integers prices, for which the i-th element is the price of a given stock on day i; and a non-negative integer fee representing a transaction fee.You may complete as many transactions as you like, but you need to pay the原创 2020-12-17 21:52:51 · 172 阅读 · 0 评论 -
290. Word Pattern(Leetcode每日一题-2020.12.16)
ProblemGiven a pattern and a string s, find if s follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s.Constraints:1 <= pattern.length <= 300pattern contain原创 2020-12-16 20:59:48 · 172 阅读 · 0 评论 -
217. Contains Duplicate(Leetcode每日一题-2020.12.13)
ProblemGiven an array of integers, find if the array contains any duplicates.Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.Example1Input: [1,2,3,1]Output: tr原创 2020-12-16 20:56:53 · 104 阅读 · 0 评论 -
738. Monotone Increasing Digits(Leetcode每日一题-2020.12.15)--抄答案
ProblemGiven a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits.(Recall that an integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.E原创 2020-12-15 21:06:31 · 144 阅读 · 0 评论 -
49. Group Anagrams(Leetcode每日一题-2020.12.14)
ProblemGiven an array of strings strs, group the anagrams together. You can return the answer in any order.An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly on原创 2020-12-14 21:03:03 · 207 阅读 · 0 评论 -
376. Wiggle Subsequence(Leetcode每日一题-2020.12.12)
ProblemA sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than tw原创 2020-12-12 19:12:43 · 189 阅读 · 0 评论 -
649. Dota2 Senate(Leetcode每日一题-2020.12.11)--抄答案
Solutionclass Solution {public: string predictPartyVictory(string senate) { int n = senate.size(); queue<int> radiant, dire; for (int i = 0; i < n; ++i) { if (senate[i] == 'R') { radiant.pu原创 2020-12-11 20:13:30 · 109 阅读 · 0 评论 -
860. Lemonade Change(Leetcode每日一题-2020.12.10)--抄答案
ProblemAt a lemonade stand, each lemonade costs $5.Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills).Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You mus原创 2020-12-10 19:56:39 · 134 阅读 · 0 评论 -
62. Unique Paths(Leetcode每日一题-2020.12.09)
ProblemA robot is located at the top-left corner of a m x n grid (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原创 2020-12-09 20:16:25 · 91 阅读 · 0 评论 -
842. Split Array into Fibonacci Sequence(Leetcode每日一题-2020.12.08)
ProblemGiven a string S of digits, such as S = “123456579”, we can split it into a Fibonacci-like sequence [123, 456, 579].Formally, a Fibonacci-like sequence is a list F of non-negative integers such that:0 <= F[i] <= 2^31 - 1, (that is, each int原创 2020-12-08 21:52:34 · 130 阅读 · 0 评论 -
861. Score After Flipping Matrix(Leetcode每日一题-2020.12.07)
ProblemWe have a two dimensional matrix A where each value is 0 or 1.A move consists of choosing any row or column, and toggling each value in that row or column: changing all 0s to 1s, and all 1s to 0s.After making any number of moves, every row of thi原创 2020-12-07 20:59:40 · 150 阅读 · 0 评论 -
118. Pascal‘s Triangle(Leetcode每日一题-2020.12.06)
ProblemGiven a non-negative integer numRows, generate the first numRows of Pascal’s triangle.In Pascal’s triangle, each number is the sum of the two numbers directly above it.ExampleSolutionclass Solution {public: vector<vector<int>>原创 2020-12-06 20:05:24 · 133 阅读 · 0 评论 -
621. Task Scheduler(Leetcode每日一题-2020.12.05)--抄答案
ProblemGiven a characters array tasks, representing the tasks a CPU needs to do, where each letter represents a different task. Tasks could be done in any order. Each task is done in one unit of time. For each unit of time, the CPU could complete either o原创 2020-12-05 08:33:32 · 210 阅读 · 0 评论 -
659. Split Array into Consecutive Subsequences(Leetcode每日一题-2020.12.04)--抄答案
ProblemGiven an array nums sorted in ascending order, return true if and only if you can split it into 1 or more subsequences such that each subsequence consists of consecutive integers and has length at least 3.Constraints:1 <= nums.length <= 10原创 2020-12-05 08:30:21 · 147 阅读 · 0 评论 -
204. Count Primes(Leetcode每日一题-2020.12.03)
ProblemCount the number of prime numbers less than a non-negative number, n.Constraints:0 <= n <= 5 * 106Example1Input: n = 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.Example2Input: n = 0Output:原创 2020-12-03 20:54:58 · 151 阅读 · 0 评论 -
321. Create Maximum Number(Leetcode每日一题-2020.12.02)--抄答案
ProblemGiven two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the same array must be preserved. Return an array of the k原创 2020-12-03 20:52:46 · 157 阅读 · 0 评论 -
34. Find First and Last Position of Element in Sorted Array(Leetcode每日一题-2020.12.01)
ProblemGiven an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.If target is not found in the array, return [-1, -1].Follow up: Could you write an algorithm with O(log n) runtime complexity原创 2020-12-01 21:54:40 · 137 阅读 · 0 评论