原文链接: 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/merge-k-sorted-lists 英文原文You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. Example 1: Input: lis…
原文链接: https://leetcode-cn.com/problems/maximum-subarray 英文原文Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. Example …
原文链接: https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal 英文原文Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the s…
原文链接: https://leetcode-cn.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal 英文原文Given two integer arrays inorder and postorder where inorder is the inorder traversal of a binary tree and postorder is the postorder traversal of t…
原文链接: https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree 英文原文Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. A height-balanced binary tree is a…
原文链接: https://leetcode-cn.com/problems/convert-sorted-list-to-binary-search-tree 英文原文Given the head of a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary …
原文链接: https://leetcode-cn.com/problems/majority-element 英文原文Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element a…
原文链接: https://leetcode-cn.com/problems/reverse-bits 英文原文Reverse bits of a given 32 bits unsigned integer. Note: Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signe…
原文链接: https://leetcode-cn.com/problems/kth-largest-element-in-an-array 英文原文Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct el…
原文链接: https://leetcode-cn.com/problems/the-skyline-problem 英文原文A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return …
原文链接: 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/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/top-k-frequent-elements 英文原文Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] …
原文链接: https://leetcode-cn.com/problems/super-pow 英文原文Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array. Example 1: Input: a = 2, b = [3] Output: 8 Example 2:…
原文链接: https://leetcode-cn.com/problems/longest-substring-with-at-least-k-repeating-characters 英文原文Given 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 greate…
原文链接: https://leetcode-cn.com/problems/reverse-pairs 英文原文Given an integer array nums, return the number of reverse pairs in the array. A reverse pair is a pair (i, j) where 0 <= i < j < nums.length and nums[i] > 2 * nums[j]. Example 1: Input: nums = …
原文链接: https://leetcode-cn.com/problems/maximum-binary-tree 英文原文You are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm: Create a root node whose value is the maxim…
原文链接: https://leetcode-cn.com/problems/construct-quad-tree 英文原文Given a n * n matrix grid of 0's and 1's only. We want to represent the grid with a Quad-Tree. Return the root of the Quad-Tree representing the grid. Notice that you can assign the value…
原文链接: https://leetcode-cn.com/problems/logical-or-of-two-binary-grids-represented-as-quad-trees 英文原文A Binary Matrix is a matrix in which all the elements are either 0 or 1. Given quadTree1 and quadTree2. quadTree1 represents a n * n binary matrix and…
原文链接: https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal 英文原文Given two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the …
原文链接: https://leetcode-cn.com/problems/sort-an-array 英文原文Given an array of integers nums, sort the array in ascending order. Example 1: Input: nums = [5,2,3,1] Output: [1,2,3,5] Example 2: Input: nums = [5,1,1,2,0,0] Output: [0,0,1,1,2,5] Constraints…
原文链接: https://leetcode-cn.com/problems/beautiful-array 英文原文An array nums of length n is beautiful if: nums is a permutation of the integers in the range [1, n]. For every 0 <= i < j < n, there is no index k with i < k < j where 2 * nums[k] == nums[i]…
原文链接: https://leetcode-cn.com/problems/k-closest-points-to-origin 英文原文Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0). The distance between two…
原文链接: https://leetcode-cn.com/problems/balance-a-binary-search-tree 英文原文Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them. A binary search tree…
原文链接: https://leetcode-cn.com/problems/number-of-ways-to-reorder-array-to-get-same-bst 英文原文Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nu…
原文链接: 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/find-array-given-subset-sums 英文原文You are given an integer n representing the length of an unknown array that you are trying to recover. You are also given an array sums containing the values of all 2n subset sum…
原文链接: https://leetcode-cn.com/problems/find-the-kth-largest-integer-in-the-array 英文原文You are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros. Return the string that represents the kth l…
1 / 2