原文链接: https://leetcode-cn.com/problems/3sum 英文原文Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain…
标签详情
排序 分类
原文链接: https://leetcode-cn.com/problems/4sum 英文原文Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a, b, c, d < n a, b, c, and d are distinct. nums[a] + nums[b] + nums…
原文链接: https://leetcode-cn.com/problems/merge-intervals 英文原文Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the inpu…
原文链接: https://leetcode-cn.com/problems/sort-colors 英文原文Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. We will use t…
原文链接: https://leetcode-cn.com/problems/merge-sorted-array 英文原文You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1…
原文链接: https://leetcode-cn.com/problems/insertion-sort-list 英文原文Given the head of a singly linked list, sort the list using insertion sort, and return the sorted list's head. The steps of the insertion sort algorithm: Insertion sort iterates, consumin…
原文链接: https://leetcode-cn.com/problems/maximum-gap 英文原文Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0. You must write an algorithm …
原文链接: 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/largest-number 英文原文Given a list of non-negative integers nums, arrange them such that they form the largest number. Note: The result may be very large, so you need to return a string instead of an integer. Examp…
原文链接: 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/contains-duplicate 英文原文Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Example 1: Input: nums = [1,2,3,1] Output: true Ex…
原文链接: https://leetcode-cn.com/problems/contains-duplicate-iii 英文原文Given an integer array nums and two integers k and t, return true if there are two distinct indices i and j in the array such that abs(nums[i] - nums[j]) <= t and abs(i - j) <= k. Exam…
原文链接: https://leetcode-cn.com/problems/majority-element-ii 英文原文Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. Example 1: Input: nums = [3,2,3] Output: [3] Example 2: Input: nums = [1] Output: [1…
原文链接: https://leetcode-cn.com/problems/valid-anagram 英文原文Given two strings s and t, return true if t is an anagram of s, and false otherwise. Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 2: Input: s = "rat", t = "car" Output: f…
原文链接: https://leetcode-cn.com/problems/missing-number 英文原文Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: Input: nums = [3,0,1] Output: 2 Explanatio…
原文链接: https://leetcode-cn.com/problems/h-index 英文原文Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return compute the researcher's h-index. According to the definition of h…
原文链接: https://leetcode-cn.com/problems/find-median-from-data-stream 英文原文The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value and the median is the mean of the two middle values. For exam…
原文链接: 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/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/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/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/find-the-difference 英文原文You are given two strings s and t. String t is generated by random shuffling string s and then add one more letter at a random position. Return the letter that was added to t. Example 1: …
原文链接: https://leetcode-cn.com/problems/queue-reconstruction-by-height 英文原文You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order). Each people[i] = [hi, ki] represents the ith person of …
原文链接: https://leetcode-cn.com/problems/third-maximum-number 英文原文Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum number. Example 1: Input: nums = [3,2,1] Outp…
原文链接: https://leetcode-cn.com/problems/non-overlapping-intervals 英文原文Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlappin…
原文链接: 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…
原文链接: https://leetcode-cn.com/problems/sort-characters-by-frequency 英文原文Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string. Return the s…
原文链接: https://leetcode-cn.com/problems/assign-cookies 英文原文Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor g[i], which is the minimum siz…
原文链接: https://leetcode-cn.com/problems/minimum-moves-to-equal-array-elements-ii 英文原文Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal. In one move, you can increment or decrement an el…
1 / 7