原文链接: 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-nth-node-from-end-of-list 英文原文Given the head of a linked list, remove the nth node from the end of the list and return its head. Example 1: Input: head = [1,2,3,4,5], n = 2 Output: [1,2,3,5] Example 2: In…
原文链接: 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/implement-strstr 英文原文Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Clarification: What should we return when needle is an empty stri…
原文链接: 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/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/rotate-list 英文原文Given the head of a linked list, rotate the list to the right by k places. Example 1: Input: head = [1,2,3,4,5], k = 2 Output: [4,5,1,2,3] Example 2: Input: head = [0,1,2], k = 4 Output: [2,0,1] …
原文链接: 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/remove-duplicates-from-sorted-array-ii 英文原文Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative order of t…
原文链接: https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii 英文原文Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted…
原文链接: https://leetcode-cn.com/problems/partition-list 英文原文Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the…
原文链接: 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/valid-palindrome 英文原文A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric …
原文链接: https://leetcode-cn.com/problems/linked-list-cycle 英文原文Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by conti…
原文链接: https://leetcode-cn.com/problems/linked-list-cycle-ii 英文原文Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null. There is a cycle in a linked list if there is some node in the list that can b…
原文链接: https://leetcode-cn.com/problems/reorder-list 英文原文You are given the head of a singly linked-list. The list can be represented as: L0 → L1 → … → Ln - 1 → Ln Reorder the list to be on the following form: L0 → Ln &r…
原文链接: https://leetcode-cn.com/problems/reverse-words-in-a-string 英文原文Given an input string s, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space. Return a st…
原文链接: https://leetcode-cn.com/problems/intersection-of-two-linked-lists 英文原文Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null…
原文链接: https://leetcode-cn.com/problems/compare-version-numbers 英文原文Given two version numbers, version1 and version2, compare them. Version numbers consist of one or more revisions joined by a dot '.'. Each revision consists of digits and may contain …
原文链接: 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/rotate-array 英文原文Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Input: nums = [1,2,3,4,5,6,7], k = 3 Output: [5,6,7,1,2,3,4] Explanation: rotate 1 steps to the righ…
原文链接: https://leetcode-cn.com/problems/happy-number 英文原文Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squa…
原文链接: https://leetcode-cn.com/problems/palindrome-linked-list 英文原文Given the head of a singly linked list, return true if it is a palindrome. Example 1: Input: head = [1,2,2,1] Output: true Example 2: Input: head = [1,2] Output: false Constraints: The…
原文链接: https://leetcode-cn.com/problems/move-zeroes 英文原文Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a copy of the array. E…
原文链接: 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/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/reverse-string 英文原文Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory. Example 1: Input:…
原文链接: https://leetcode-cn.com/problems/reverse-vowels-of-a-string 英文原文Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases. Example 1: Input: s = "hel…
1 / 5