原文链接: https://leetcode-cn.com/problems/median-of-two-sorted-arrays 英文原文Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1…
标签详情
二分查找 分类
原文链接: https://leetcode-cn.com/problems/search-in-rotated-sorted-array 英文原文There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1…
原文链接: https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array 英文原文Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found i…
原文链接: https://leetcode-cn.com/problems/search-insert-position 英文原文Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must…
原文链接: https://leetcode-cn.com/problems/sqrtx 英文原文Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned. Note…
原文链接: https://leetcode-cn.com/problems/search-a-2d-matrix 英文原文Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer o…
原文链接: https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array 英文原文Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: [4,5,6,7,0,1,2] if it…
原文链接: https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii 英文原文Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become: [4,5,6,7,0,1,4] if…
原文链接: https://leetcode-cn.com/problems/find-peak-element 英文原文A peak element is an element that is strictly greater than its neighbors. Given an integer array nums, find a peak element, and return its index. If the array contains multiple peaks, retur…
原文链接: https://leetcode-cn.com/problems/two-sum-ii-input-array-is-sorted 英文原文Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two …
原文链接: https://leetcode-cn.com/problems/minimum-size-subarray-sum 英文原文Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray [numsl, numsl+1, ..., numsr-1, numsr] of which the sum is …
原文链接: https://leetcode-cn.com/problems/count-complete-tree-nodes 英文原文Given the root of a complete binary tree, return the number of the nodes in the tree. According to Wikipedia, every level, except possibly the last, is completely filled in a comple…
原文链接: https://leetcode-cn.com/problems/search-a-2d-matrix-ii 英文原文Write an efficient algorithm that searches for a target value in an m x n integer matrix. The matrix has the following properties: Integers in each row are sorted in ascending from left…
原文链接: https://leetcode-cn.com/problems/h-index-ii 英文原文Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper and citations is sorted in an ascending order, return compute the resea…
原文链接: https://leetcode-cn.com/problems/first-bad-version 英文原文You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed b…
原文链接: https://leetcode-cn.com/problems/find-the-duplicate-number 英文原文Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nums, return this repeated number…
原文链接: https://leetcode-cn.com/problems/longest-increasing-subsequence 英文原文Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is a sequence that can be derived from an array by deleting some or…
原文链接: https://leetcode-cn.com/problems/count-of-smaller-numbers-after-self 英文原文You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the r…
原文链接: https://leetcode-cn.com/problems/count-of-range-sum 英文原文Given an integer array nums and two integers lower and upper, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) is defined as the sum of the elements …
原文链接: https://leetcode-cn.com/problems/intersection-of-two-arrays 英文原文Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order. Example 1: In…
原文链接: https://leetcode-cn.com/problems/intersection-of-two-arrays-ii 英文原文Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you may retu…
原文链接: https://leetcode-cn.com/problems/data-stream-as-disjoint-intervals 英文原文Given a data stream input of non-negative integers a1, a2, ..., an, summarize the numbers seen so far as a list of disjoint intervals. Implement the SummaryRanges class: Sum…
原文链接: https://leetcode-cn.com/problems/russian-doll-envelopes 英文原文You are given a 2D array of integers envelopes where envelopes[i] = [wi, hi] represents the width and the height of an envelope. One envelope can fit into another if and only if both t…
原文链接: https://leetcode-cn.com/problems/max-sum-of-rectangle-no-larger-than-k 英文原文Given an m x n matrix matrix and an integer k, return the max sum of a rectangle in the matrix such that its sum is no larger than k. It is guaranteed that there will be…
原文链接: https://leetcode-cn.com/problems/valid-perfect-square 英文原文Given a positive integer num, write a function which returns True if num is a perfect square else False. Follow up: Do not use any built-in library function such as sqrt. Example 1: Inpu…
原文链接: https://leetcode-cn.com/problems/guess-number-higher-or-lower 英文原文We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I will tell you whether t…
原文链接: https://leetcode-cn.com/problems/kth-smallest-element-in-a-sorted-matrix 英文原文Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the kth smallest element in the matrix. Note that it is the kth smallest …
原文链接: https://leetcode-cn.com/problems/nth-digit 英文原文Given an integer n, return the nth digit of the infinite integer sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]. Example 1: Input: n = 3 Output: 3 Example 2: Input: n = 11 Output: 0 Explanation:…
原文链接: https://leetcode-cn.com/problems/split-array-largest-sum 英文原文Given an array nums which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest…
原文链接: https://leetcode-cn.com/problems/find-right-interval 英文原文You are given an array of intervals, where intervals[i] = [starti, endi] and each starti is unique. The right interval for an interval i is an interval j such that startj >= endi and star…
1 / 5