原文链接: 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/is-subsequence 英文原文Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can b…
原文链接: https://leetcode-cn.com/problems/string-compression 英文原文Given an array of characters chars, compress it using the following algorithm: Begin with an empty string s. For each group of consecutive repeating characters in chars: If the group's len…
原文链接: https://leetcode-cn.com/problems/circular-array-loop 英文原文You are playing a game involving a circular array of non-zero integers nums. Each nums[i] denotes the number of indices forward/backward you must move if you are located at index i: If nu…
原文链接: https://leetcode-cn.com/problems/magical-string 英文原文A magical string s consists of only '1' and '2' and obeys the following rules: The string s is magical because concatenating the number of contiguous occurrences of characters '1' and '2' gene…
原文链接: https://leetcode-cn.com/problems/longest-uncommon-subsequence-ii 英文原文Given an array of strings strs, return the length of the longest uncommon subsequence between them. If the longest uncommon subsequence does not exist, return -1. An uncommon …
原文链接: https://leetcode-cn.com/problems/longest-word-in-dictionary-through-deleting 英文原文Given a string s and a string array dictionary, return the longest string in the dictionary that can be formed by deleting some of the given string characters. If …
原文链接: https://leetcode-cn.com/problems/swapping-nodes-in-a-linked-list 英文原文You are given the head of a linked list, and an integer k. Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node fro…
原文链接: https://leetcode-cn.com/problems/reverse-string-ii 英文原文Given a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string. If there are fewer than k characters left, reverse all of th…
原文链接: https://leetcode-cn.com/problems/next-greater-element-iii 英文原文Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive integer exists, …
原文链接: https://leetcode-cn.com/problems/reverse-words-in-a-string-iii 英文原文Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: s = "Let's take Leet…
原文链接: https://leetcode-cn.com/problems/permutation-in-string 英文原文Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1's permutations is the substring of s2. Example …
原文链接: https://leetcode-cn.com/problems/shortest-unsorted-continuous-subarray 英文原文Given an integer array nums, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in asce…
原文链接: https://leetcode-cn.com/problems/valid-triangle-number 英文原文Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. Example 1: Input: nums = [2,2,3,4…
原文链接: https://leetcode-cn.com/problems/sum-of-square-numbers 英文原文Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Input: c = 5 Output: true Explanation: 1 * 1 + 2 * 2 = 5 Example 2: Input:…
原文链接: https://leetcode-cn.com/problems/two-sum-iv-input-is-a-bst 英文原文Given the root of a Binary Search Tree and a target number k, return true if there exist two elements in the BST such that their sum is equal to the given target. Example 1: Input: …
原文链接: https://leetcode-cn.com/problems/find-k-closest-elements 英文原文Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order. An integer a is closer to…
原文链接: https://leetcode-cn.com/problems/valid-palindrome-ii 英文原文Given a string s, return true if the s can be palindrome after deleting at most one character from it. Example 1: Input: s = "aba" Output: true Example 2: Input: s = "abca" Output: true E…
原文链接: https://leetcode-cn.com/problems/count-binary-substrings 英文原文Give a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutive…
原文链接: https://leetcode-cn.com/problems/find-k-th-smallest-pair-distance 英文原文The distance of a pair of integers a and b is defined as the absolute difference between a and b. Given an integer array nums and an integer k, return the kth smallest distan…
原文链接: https://leetcode-cn.com/problems/partition-labels 英文原文You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. Return a list of integers representing the size of t…
原文链接: https://leetcode-cn.com/problems/swap-adjacent-in-lr-string 英文原文In a string composed of 'L', 'R', and 'X' characters, like "RXXLRXRXL", a move consists of either replacing one occurrence of "XL" with "LX", or replacing one occurrence of "RX" wi…
原文链接: https://leetcode-cn.com/problems/number-of-subarrays-with-bounded-maximum 英文原文Given an integer array nums and two integers left and right, return the number of contiguous non-empty subarrays such that the value of the maximum array element in t…
原文链接: https://leetcode-cn.com/problems/expressive-words 英文原文Sometimes people repeat letters to represent extra feeling. For example: "hello" -> "heeellooo" "hi" -> "hiiii" In these strings like "heeellooo", we have groups of adjacent letters that are…
原文链接: https://leetcode-cn.com/problems/shortest-distance-to-a-character 英文原文Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the clos…
原文链接: https://leetcode-cn.com/problems/friends-of-appropriate-ages 英文原文There are n persons on a social media website. You are given an integer array ages where ages[i] is the age of the ith person. A Person x will not send a friend request to a perso…
原文链接: https://leetcode-cn.com/problems/most-profit-assigning-work 英文原文You have n jobs and m workers. You are given three arrays: difficulty, profit, and worker where: difficulty[i] and profit[i] are the difficulty and the profit of the ith job, and w…
原文链接: https://leetcode-cn.com/problems/flipping-an-image 英文原文Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed. …
原文链接: https://leetcode-cn.com/problems/push-dominoes 英文原文There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right. After each second,…