原文链接: https://leetcode-cn.com/problems/two-sum 英文原文Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may n…
标签详情
数组 分类
原文链接: 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/container-with-most-water 英文原文Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, a…
原文链接: 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/remove-duplicates-from-sorted-array 英文原文Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the eleme…
原文链接: https://leetcode-cn.com/problems/next-permutation 英文原文Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such an arrangement is not possible, it must rearrange it as the lowes…
原文链接: 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/valid-sudoku 英文原文Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the digits 1-9 without repetition. Each column must…
原文链接: https://leetcode-cn.com/problems/sudoku-solver 英文原文Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits 1-9 must occur exactly once in each row. Each …
原文链接: https://leetcode-cn.com/problems/combination-sum 英文原文Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the c…
原文链接: https://leetcode-cn.com/problems/combination-sum-ii 英文原文Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target. Each number in cand…
原文链接: https://leetcode-cn.com/problems/first-missing-positive 英文原文Given an unsorted integer array nums, return the smallest missing positive integer. You must implement an algorithm that runs in O(n) time and uses constant extra space. Example 1: Inp…
原文链接: https://leetcode-cn.com/problems/trapping-rain-water 英文原文Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: Input: height = [0,1,0,2,1,0,1,3…
原文链接: https://leetcode-cn.com/problems/jump-game-ii 英文原文Given an array of non-negative integers nums, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your g…
原文链接: https://leetcode-cn.com/problems/permutations 英文原文Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],…
原文链接: https://leetcode-cn.com/problems/permutations-ii 英文原文Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order. Example 1: Input: nums = [1,1,2] Output: [[1,1,2], [1,2,1], [2,1,1]] …
原文链接: https://leetcode-cn.com/problems/rotate-image 英文原文You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix dire…
原文链接: https://leetcode-cn.com/problems/n-queens 英文原文The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. You…
原文链接: 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/spiral-matrix 英文原文Given an m x n matrix, return all elements of the matrix in spiral order. Example 1: Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,3,6,9,8,7,4,5] Example 2: Input: matrix = [[1,2,3,4],…
原文链接: https://leetcode-cn.com/problems/jump-game 英文原文You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position. Return true if you …
原文链接: 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/insert-interval 英文原文You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in ascending orde…
原文链接: https://leetcode-cn.com/problems/spiral-matrix-ii 英文原文Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order. Example 1: Input: n = 3 Output: [[1,2,3],[8,9,4],[7,6,5]] Example 2: Input: n = 1 Outp…
原文链接: https://leetcode-cn.com/problems/unique-paths-ii 英文原文A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reac…
原文链接: https://leetcode-cn.com/problems/minimum-path-sum 英文原文Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. Note: You can only move either down or …
原文链接: https://leetcode-cn.com/problems/plus-one 英文原文You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-…
1 / 29