原文链接: https://leetcode-cn.com/problems/magnetic-force-between-two-balls 英文原文In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith …
标签详情
二分查找 分类
原文链接: https://leetcode-cn.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted 英文原文Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing. Return the length of the…
原文链接: https://leetcode-cn.com/problems/find-latest-group-of-size-m 英文原文Given an array arr that represents a permutation of numbers from 1 to n. You have a binary string of size n that initially has all its bits set to zero. At each step i (assuming b…
原文链接: https://leetcode-cn.com/problems/special-array-with-x-elements-greater-than-or-equal-x 英文原文You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums…
原文链接: https://leetcode-cn.com/problems/path-with-minimum-effort 英文原文You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are si…
原文链接: https://leetcode-cn.com/problems/minimum-number-of-removals-to-make-mountain-array 英文原文You may recall that an array arr is a mountain array if and only if: arr.length >= 3 There exists some index i (0-indexed) with 0 < i < arr.length - 1 such t…
原文链接: https://leetcode-cn.com/problems/sell-diminishing-valued-colored-balls 英文原文You have an inventory of different colored balls, and there is a customer that wants orders balls of any color. The customer weirdly values the colored balls. Each color…
原文链接: https://leetcode-cn.com/problems/minimum-operations-to-reduce-x-to-zero 英文原文You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its…
原文链接: https://leetcode-cn.com/problems/minimum-interval-to-include-each-query 英文原文You are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive). The size…
原文链接: https://leetcode-cn.com/problems/maximum-distance-between-a-pair-of-values 英文原文You are given two non-increasing 0-indexed integer arrays nums1 and nums2. A pair of indices (i, j), where 0 <= i < nums1.length and 0 <= j < nums2.lengt…
原文链接: https://leetcode-cn.com/problems/minimum-speed-to-arrive-on-time 英文原文You are given a floating-point number hour, representing the amount of time you have to reach the office. To commute to the office, you must take n trains in sequential order.…
原文链接: https://leetcode-cn.com/problems/find-the-student-that-will-replace-the-chalk 英文原文There are n students in a class numbered from 0 to n - 1. The teacher will give each student a problem starting with the student number 0, then the student number…
原文链接: https://leetcode-cn.com/problems/minimum-space-wasted-from-packaging 英文原文You have n packages that you are trying to place in boxes, one package in each box. There are m suppliers that each produce boxes of different sizes (with infinite supply)…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-removable-characters 英文原文You are given two strings s and p where p is a subsequence of s. You are also given a distinct 0-indexed integer array removable containing a subset of indices of s (s …
原文链接: https://leetcode-cn.com/problems/find-a-peak-element-ii 英文原文A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom. Given a 0-indexed m x n matrix mat where no t…
原文链接: https://leetcode-cn.com/problems/longest-common-subpath 英文原文There is a country of n cities numbered from 0 to n - 1. In this country, there is a road connecting every pair of cities. There are m friends numbered from 0 to m - 1 who are travelin…
原文链接: https://leetcode-cn.com/problems/merge-bsts-to-create-single-bst 英文原文You are given n BST (binary search tree) root nodes for n separate BSTs stored in an array trees (0-indexed). Each BST in trees has at most 3 nodes, and no two roots have the …
原文链接: https://leetcode-cn.com/problems/find-the-longest-valid-obstacle-course-at-each-position 英文原文You want to build some obstacle courses. You are given a 0-indexed integer array obstacles of length n, where obstacles[i] describes the height of the …
原文链接: https://leetcode-cn.com/problems/last-day-where-you-can-still-cross 英文原文There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matri…
原文链接: https://leetcode-cn.com/problems/maximum-earnings-from-taxi 英文原文There are n points on a road you are driving your taxi on. The n points on the road are labeled from 1 to n in the direction you are going, and you want to drive from point 1 to po…
原文链接: https://leetcode-cn.com/problems/minimum-number-of-operations-to-make-array-continuous 英文原文You are given an integer array nums. In one operation, you can replace any element in nums with any integer. nums is considered continuous if both of the…
原文链接: https://leetcode-cn.com/problems/maximize-the-confusion-of-an-exam 英文原文A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecut…
原文链接: https://leetcode-cn.com/problems/kth-smallest-product-of-two-sorted-arrays 英文原文Given two sorted 0-indexed integer arrays nums1 and nums2 as well as an integer k, return the kth (1-based) smallest product of nums1[i] * nums2[j] where 0 <= i < nu…
原文链接: https://leetcode-cn.com/problems/partition-array-into-two-arrays-to-minimize-sum-difference 英文原文You are given an integer array nums of 2 * n integers. You need to partition nums into two arrays of length n to minimize the absolute difference of…
原文链接: https://leetcode-cn.com/problems/two-best-non-overlapping-events 英文原文You are given a 0-indexed 2D integer array of events where events[i] = [startTimei, endTimei, valuei]. The ith event starts at startTimei and ends at endTimei, and if you atte…
原文链接: https://leetcode-cn.com/problems/plates-between-candles 英文原文There is a long table with a line of plates and candles arranged on top of it. You are given a 0-indexed string s consisting of characters '*' and '|' only, where a '*' represents a pl…
原文链接: https://leetcode-cn.com/problems/most-beautiful-item-for-each-query 英文原文You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively. You are also given a 0-indexed integer array…
原文链接: https://leetcode-cn.com/problems/minimized-maximum-of-products-distributed-to-any-store 英文原文You are given an integer n indicating there are n specialty retail stores. There are m product types of varying amounts, which are given as a 0-indexed …
原文链接: https://leetcode-cn.com/problems/find-target-indices-after-sorting-array 英文原文You are given a 0-indexed integer array nums and a target element target. A target index is an index i such that nums[i] == target. Return a list of the target indices…
原文链接: https://leetcode-cn.com/problems/search-rotate-array-lcci 英文原文Given a sorted array of n integers that has been rotated an unknown number of times, write code to find an element in the array. You may assume that the array was originally sorted i…