leetcode每日一题202102
文章平均质量分 61
Bryan要加油
这个作者很懒,什么都没留下…
展开
-
896. Monotonic Array(Leetcode每日一题-2021.02.28)
ProblemAn array is monotonic if it is either monotone increasing or monotone decreasing.An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if for all i <= j, A[i] >= A[j].Return true if and原创 2021-02-28 22:11:38 · 136 阅读 · 0 评论 -
395. Longest Substring with At Least K Repeating Characters(Leetcode每日一题-2021.02.27)--抄答案
ProblemGiven a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is greater than or equal to k.Constraints:1 <= s.length <= 10^4s consists of only lowercase Eng原创 2021-02-27 21:28:39 · 166 阅读 · 0 评论 -
1178. Number of Valid Words for Each Puzzle(Leetcode每日一题-2021.02.26)--抄答案
ProblemWith respect to a given puzzle string, a word is valid if both the following conditions are satisfied:word contains the first letter of puzzle.For each letter in word, that letter is in puzzle.For example, if the puzzle is “abcdefg”, then valid原创 2021-02-26 20:31:33 · 270 阅读 · 0 评论 -
867. Transpose Matrix(Leetcode每日一题-2021.02.25)
ProblemGiven a 2D integer array matrix, return the transpose of matrix.The transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix’s row and column indices.Constraints:m == matrix.lengthn == matrix[i].length1 <= m原创 2021-02-25 18:54:40 · 180 阅读 · 0 评论 -
832. Flipping an Image(Leetcode每日一题-2021.02.24)
ProblemGiven a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means that each row of the image is reversed. For example, flipping [1, 1, 0] horizontally results in [0原创 2021-02-24 17:44:12 · 128 阅读 · 0 评论 -
1052. Grumpy Bookstore Owner(Leetcode每日一题-2021.02.23)
ProblemToday, the bookstore owner has a store open for customers.length minutes. Every minute, some number of customers (customers[i]) enter the store, and all those customers leave after the end of that minute.On some minutes, the bookstore owner is gr原创 2021-02-23 20:10:24 · 215 阅读 · 0 评论 -
766. Toeplitz Matrix(Leetcode每日一题-2021.02.22)
ProblemGiven an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false.A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements.Constraints:m == matrix.lengthn == matrix[i].length1 <= m, n &原创 2021-02-22 19:18:11 · 155 阅读 · 0 评论 -
1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal (Leetcode每日一题-2021.02.21)
ProblemGiven an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit.Constraints:1 <= nums.length &l原创 2021-02-21 20:41:20 · 190 阅读 · 0 评论 -
697. Degree of an Array(Leetcode每日一题-2021.02.20)
ProblemGiven a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.Your task is to find the smallest possible length of a (contiguous) subarray of nums, that has the same原创 2021-02-20 17:43:31 · 157 阅读 · 0 评论 -
1004. Max Consecutive Ones III(Leetcode每日一题-2021.02.19)
ProblemGiven an array A of 0s and 1s, we may change up to K values from 0 to 1.Return the length of the longest (contiguous) subarray that contains only 1s.Note:1 <= A.length <= 200000 <= K <= A.lengthA[i] is 0 or 1Example1Input: A =原创 2021-02-19 18:56:58 · 127 阅读 · 0 评论 -
995. Minimum Number of K Consecutive Bit Flips(Leetcode每日一题-2021.02.18)--抄答案
ProblemIn an array A containing only 0s and 1s, a K-bit flip consists of choosing a (contiguous) subarray of length K and simultaneously changing every 0 in the subarray to 1, and every 1 in the subarray to 0.Return the minimum number of K-bit flips requ原创 2021-02-18 18:55:09 · 143 阅读 · 0 评论 -
566. Reshape the Matrix(Leetcode每日一题-2021.02.17)
ProblemIn MATLAB, there is a very useful function called ‘reshape’, which can reshape a matrix into a new one with different size but keep its original data.You’re given a matrix represented by a two-dimensional array, and two positive integers r and c r原创 2021-02-17 18:15:15 · 152 阅读 · 0 评论 -
561. Array Partition I(Leetcode每日一题-2021.02.16)
ProblemGiven an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), …, (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized sum.Constraints:1 <= n <= 10^4nums.length == 2 * n原创 2021-02-16 09:17:17 · 154 阅读 · 0 评论 -
485. Max Consecutive Ones(Leetcode每日一题-2021.02.15)
ProblemGiven a binary array, find the maximum number of consecutive 1s in this array.Note:The input array will only contain 0 and 1.The length of input array is a positive integer and will not exceed 10,000ExampleInput: [1,1,0,1,1,1]Output: 3Exp原创 2021-02-15 10:27:49 · 144 阅读 · 0 评论 -
765. Couples Holding Hands(Leetcode每日一题-2021.02.14)--抄答案
ProblemN couples sit in 2N seats arranged in a row and want to hold hands. We want to know the minimum number of swaps so that every couple is sitting side by side. A swap consists of choosing any two people, then they stand up and switch seats.The peopl原创 2021-02-15 10:24:44 · 207 阅读 · 0 评论 -
448. Find All Numbers Disappeared in an Array(Leetcode每日一题-2021.02.13)
ProblemGiven an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Could you do it without extra space and in O(n) runtim原创 2021-02-13 10:01:13 · 73 阅读 · 0 评论 -
119. Pascal‘s Triangle II(Leetcode每日一题-2021.02.12)
ProblemGiven an integer rowIndex, return the rowIndexth row of the Pascal’s triangle.Notice that the row index starts from 0.In Pascal’s triangle, each number is the sum of the two numbers directly above it.Constraints:0 <= rowIndex <= 33Exam原创 2021-02-12 12:23:12 · 124 阅读 · 0 评论 -
703. Kth Largest Element in a Stream(Leetcode每日一题-2021.02.11)
ProblemDesign a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.Implement KthLargest class:KthLargest(int k, int[] nums) Initializes the object with the integer原创 2021-02-11 09:53:16 · 172 阅读 · 0 评论 -
567. Permutation in String(Leetcode每日一题-2021.02.10)
ProblemGiven two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string’s permutations is the substring of the second string.Constraints:The input strings only contain lower case原创 2021-02-10 19:48:38 · 126 阅读 · 0 评论 -
992. Subarrays with K Different Integers(Leetcode每日一题-2021.02.09)--抄答案
ProblemGiven an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A good if the number of different integers in that subarray is exactly K.(For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.)Return the原创 2021-02-09 22:41:53 · 178 阅读 · 1 评论 -
978. Longest Turbulent Subarray(Leetcode每日一题-2021.02.08)
ProblemGiven an integer array arr, return the length of a maximum size turbulent subarray of arr.A subarray is turbulent if the comparison sign flips between each adjacent pair of elements in the subarray.More formally, a subarray [arr[i], arr[i + 1], …原创 2021-02-08 21:42:27 · 147 阅读 · 0 评论 -
665. Non-decreasing Array(Leetcode每日一题-2021.02.07)--易错的简单题
ProblemGiven an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element.We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based) such that (0 <= i <=原创 2021-02-07 19:18:15 · 180 阅读 · 0 评论 -
1423. Maximum Points You Can Obtain from Cards(Leetcode每日一题-2021.02.06)
ProblemThere are several cards arranged in a row, and each card has an associated number of points The points are given in the integer array cardPoints.In one step, you can take one card from the beginning or from the end of the row. You have to take exa原创 2021-02-06 20:19:41 · 219 阅读 · 0 评论 -
1208. Get Equal Substrings Within Budget(Leetcode每日一题-2021.02.05)
ProblemYou are given two strings s and t of the same length. You want to change s to t. Changing the i-th character of s to i-th character of t costs |s[i] - t[i]| that is, the absolute difference between the ASCII values of the characters.You are also g原创 2021-02-05 19:22:25 · 130 阅读 · 0 评论 -
643. Maximum Average Subarray I(Leetcode每日一题-2021.02.04)
ProblemGiven an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value.Note:1 <= k <= n <= 30,000.Elements of the given array will be原创 2021-02-04 18:09:46 · 154 阅读 · 0 评论 -
480. Sliding Window Median(Leetcode每日一题-2021.02.03)--抄答案
ProblemMedian 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.Examples:[2,3,4] , the median is 3[2,3], the median is (2 + 3) / 2 = 2.5Given an原创 2021-02-03 19:32:53 · 191 阅读 · 0 评论 -
424. Longest Repeating Character Replacement(Leetcode每日一题-2021.02.02)--抄答案
ProblemGiven a string s that consists of only uppercase English letters, you can perform at most k operations on that string.In one operation, you can choose any character of the string and change it to any other uppercase English character.Find the len原创 2021-02-03 19:30:40 · 147 阅读 · 0 评论 -
888. Fair Candy Swap(Leetcode每日一题-2021.02.01)
ProblemAlice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of candy that Bob has.Since they are friends, they would like to exchange one candy bar each so that a原创 2021-02-01 19:20:59 · 86 阅读 · 0 评论