原文链接: https://leetcode-cn.com/problems/backspace-string-compare 英文原文Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after backspacing an empty text, the …
标签详情
双指针 分类
原文链接: https://leetcode-cn.com/problems/longest-mountain-in-array 英文原文You may recall that an array arr is a mountain array if and only if: arr.length >= 3 There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that: arr[0] < arr[1] < .…
原文链接: https://leetcode-cn.com/problems/middle-of-the-linked-list 英文原文Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. Example 1: Input: head = [1,2,3,4,5]…
原文链接: https://leetcode-cn.com/problems/boats-to-save-people 英文原文You are given an array people where people[i] is the weight of the ith person, and an infinite number of boats where each boat can carry a maximum weight of limit. Each boat carries at m…
原文链接: https://leetcode-cn.com/problems/sort-array-by-parity 英文原文Given an integer array nums, move all the even integers at the beginning of the array followed by all the odd integers. Return any array that satisfies this condition. Example 1: Input: …
原文链接: https://leetcode-cn.com/problems/reverse-only-letters 英文原文Given a string s, reverse the string according to the following rules: All the characters that are not English letters remain in the same position. All the English letters (lowercase or …
原文链接: https://leetcode-cn.com/problems/sort-array-by-parity-ii 英文原文Given an array of integers nums, half of the integers in nums are odd, and the other half are even. Sort the array so that whenever nums[i] is odd, i is odd, and whenever nums[i] is e…
原文链接: https://leetcode-cn.com/problems/3sum-with-multiplicity 英文原文Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target. As the answer can be very large, retu…
原文链接: https://leetcode-cn.com/problems/long-pressed-name 英文原文Your friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be typed 1 or more times. You examine the typed …
原文链接: https://leetcode-cn.com/problems/di-string-match 英文原文A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where: s[i] == 'I' if perm[i] < perm[i + 1], and s[i] == 'D' if perm[…
原文链接: https://leetcode-cn.com/problems/bag-of-tokens 英文原文You have an initial power of power, an initial score of 0, and a bag of tokens where tokens[i] is the value of the ith token (0-indexed). Your goal is to maximize your total score by potentiall…
原文链接: https://leetcode-cn.com/problems/pancake-sorting 英文原文Given an array of integers arr, sort the array by performing a series of pancake flips. In one pancake flip we do the following steps: Choose an integer k where 1 <= k <= arr.length. Reverse …
原文链接: https://leetcode-cn.com/problems/squares-of-a-sorted-array 英文原文Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order. Example 1: Input: nums = [-4,-1,0,3,10] Out…
原文链接: https://leetcode-cn.com/problems/interval-list-intersections 英文原文You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each list of intervals is pairwise d…
原文链接: https://leetcode-cn.com/problems/moving-stones-until-consecutive-ii 英文原文There are some stones in different positions on the X-axis. You are given an integer array stones, the positions of the stones. Call a stone an endpoint stone if it has the…
原文链接: https://leetcode-cn.com/problems/longest-string-chain 英文原文You are given an array of words where each word consists of lowercase English letters. wordA is a predecessor of wordB if and only if we can insert exactly one letter anywhere in wordA w…
原文链接: https://leetcode-cn.com/problems/last-substring-in-lexicographical-order 英文原文Given a string s, return the last substring of s in lexicographical order. Example 1: Input: s = "abab" Output: "bab" Explanation: The substrings are ["a", "ab", "aba"…
原文链接: https://leetcode-cn.com/problems/duplicate-zeros 英文原文Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond the length of the original array are not wri…
原文链接: https://leetcode-cn.com/problems/statistics-from-a-large-sample 英文原文You are given a large sample of integers in the range [0, 255]. Since the sample is so large, it is represented by an array count where count[k] is the number of times that k a…
原文链接: https://leetcode-cn.com/problems/longest-chunked-palindrome-decomposition 英文原文You are given a string text. You should split it to k substrings (subtext1, subtext2, ..., subtextk) such that: subtexti is a non-empty string. The concatenation of a…
原文链接: https://leetcode-cn.com/problems/find-positive-integer-solution-for-a-given-equation 英文原文Given a callable function f(x, y) with a hidden formula and a value z, reverse engineer the formula and return all positive integer pairs x and y where f(x…
原文链接: https://leetcode-cn.com/problems/remove-palindromic-subsequences 英文原文You are given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s. Return the minimum number of steps to make…
原文链接: https://leetcode-cn.com/problems/check-if-n-and-its-double-exist 英文原文Given an array arr of integers, check if there exists two integers N and M such that N is the double of M ( i.e. N = 2 * M). More formally check if there exists two indices i …
原文链接: https://leetcode-cn.com/problems/find-the-distance-value-between-two-arrays 英文原文Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays. The distance value is defined as the number of elements…
原文链接: https://leetcode-cn.com/problems/the-k-strongest-values-in-an-array 英文原文Given an array of integers arr and an integer k. A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array…
原文链接: https://leetcode-cn.com/problems/range-sum-of-sorted-subarray-sums 英文原文You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreas…
原文链接: https://leetcode-cn.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition 英文原文Given an array of integers nums and an integer target. Return the number of non-empty subsequences of nums such that the sum of the minimum and max…
原文链接: https://leetcode-cn.com/problems/get-the-maximum-score 英文原文You are given two sorted arrays of distinct integers nums1 and nums2. A valid path is defined as follows: Choose array nums1 or nums2 to traverse (from index-0). Traverse the current ar…
原文链接: https://leetcode-cn.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted 英文原文Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing. Return the length of the…
原文链接: https://leetcode-cn.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers 英文原文Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules: Type…