原文链接: https://leetcode-cn.com/problems/max-consecutive-ones-iii 英文原文Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's. Example 1: Input: nums = [1,1,1,0,0,0,1,1,1,1,0],…
标签详情
二分查找 分类
原文链接: https://leetcode-cn.com/problems/capacity-to-ship-packages-within-d-days 英文原文A conveyor belt has packages that must be shipped from one port to another within days days. The ith package on the conveyor belt has a weight of weights[i]. Each day,…
原文链接: https://leetcode-cn.com/problems/longest-arithmetic-subsequence 英文原文Given an array nums of integers, return the length of the longest arithmetic subsequence in nums. Recall that a subsequence of an array nums is a list nums[i1], nums[i2], ..., …
原文链接: https://leetcode-cn.com/problems/longest-duplicate-substring 英文原文Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap. Return any duplicated substring that ha…
原文链接: https://leetcode-cn.com/problems/find-in-mountain-array 英文原文(This problem is an interactive problem.) You may recall that an array arr is a mountain array if and only if: arr.length >= 3 There exists some i with 0 < i < arr.length - 1 such that…
原文链接: https://leetcode-cn.com/problems/sum-of-mutated-array-closest-to-target 英文原文Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equa…
原文链接: https://leetcode-cn.com/problems/snapshot-array 英文原文Implement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with the given length. Initially, each element equals 0. voi…
原文链接: https://leetcode-cn.com/problems/online-majority-element-in-subarray 英文原文Design a data structure that efficiently finds the majority element of a given subarray. The majority element of a subarray is an element that occurs threshold times or mo…
原文链接: https://leetcode-cn.com/problems/compare-strings-by-frequency-of-the-smallest-character 英文原文Let the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s. For example, if s = "dcce" then f(s) = 2 bec…
原文链接: https://leetcode-cn.com/problems/make-array-strictly-increasing 英文原文Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing. In one operation, you can choose two in…
原文链接: https://leetcode-cn.com/problems/kth-ancestor-of-a-tree-node 英文原文You are given a tree with n nodes numbered from 0 to n - 1 in the form of a parent array parent where parent[i] is the parent of ith node. The root of the tree is node 0. Find the…
原文链接: https://leetcode-cn.com/problems/minimum-garden-perimeter-to-collect-enough-apples 英文原文In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate. The apple tree planted at an integer coordinate (…
原文链接: https://leetcode-cn.com/problems/ugly-number-iii 英文原文An ugly number is a positive integer that is divisible by a, b, or c. Given four integers n, a, b, and c, return the nth ugly number. Example 1: Input: n = 3, a = 2, b = 3, c = 5 Output: 4 Ex…
原文链接: https://leetcode-cn.com/problems/get-equal-substrings-within-budget 英文原文You 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 ab…
原文链接: https://leetcode-cn.com/problems/sum-of-floored-pairs 英文原文Given an integer array nums, return the sum of floor(nums[i] / nums[j]) for all pairs of indices 0 <= i, j < nums.length in the array. Since the answer may be too large, return it modulo…
原文链接: https://leetcode-cn.com/problems/maximum-profit-in-job-scheduling 英文原文We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i]. You're given the startTime, endTime and profit array…
原文链接: https://leetcode-cn.com/problems/find-positive-integer-solution-for-a-given-equation 英文原文Given a callable function f(x, y) with a hidden formula and a value z, reverse engineer the formula and return all positive integer pairs x and y where f(x…
原文链接: https://leetcode-cn.com/problems/find-the-smallest-divisor-given-a-threshold 英文原文Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Fin…
原文链接: https://leetcode-cn.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold 英文原文Given a m x n matrix mat and an integer threshold. Return the maximum side-length of a square with a sum less than or equal to thresho…
原文链接: https://leetcode-cn.com/problems/the-k-weakest-rows-in-a-matrix 英文原文You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all th…
原文链接: https://leetcode-cn.com/problems/check-if-n-and-its-double-exist 英文原文Given an array arr of integers, check if there exists two integers N and M such that N is the double of M ( i.e. N = 2 * M). More formally check if there exists two indices i …
原文链接: https://leetcode-cn.com/problems/tweet-counts-per-frequency 英文原文A social media company is trying to monitor activity on their site by analyzing the number of tweets that occur in select periods of time. These periods can be partitioned into sma…
原文链接: https://leetcode-cn.com/problems/count-negative-numbers-in-a-sorted-matrix 英文原文Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid. Example 1: Input: gri…
原文链接: https://leetcode-cn.com/problems/find-the-distance-value-between-two-arrays 英文原文Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays. The distance value is defined as the number of elements…
原文链接: https://leetcode-cn.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows 英文原文You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing order. You are allowed to choose exactly 1 element fro…
原文链接: https://leetcode-cn.com/problems/minimum-number-of-days-to-make-m-bouquets 英文原文Given an integer array bloomDay, an integer m and an integer k. We need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden. Th…
原文链接: https://leetcode-cn.com/problems/avoid-flood-in-the-city 英文原文Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, the nth lake becomes full of water. If it rains over a lake whic…
原文链接: https://leetcode-cn.com/problems/range-sum-of-sorted-subarray-sums 英文原文You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreas…
原文链接: https://leetcode-cn.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition 英文原文Given an array of integers nums and an integer target. Return the number of non-empty subsequences of nums such that the sum of the minimum and max…
原文链接: https://leetcode-cn.com/problems/kth-missing-positive-number 英文原文Given an array arr of positive integers sorted in a strictly increasing order, and an integer k. Find the kth positive integer that is missing from this array. Example 1: Input: a…