原文链接: 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/add-two-numbers-ii 英文原文You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers…
原文链接: https://leetcode-cn.com/problems/number-of-boomerangs 英文原文You are given n points in the plane that are all distinct, where points[i] = [xi, yi]. A boomerang is a tuple of points (i, j, k) such that the distance between i and j equals the distan…
原文链接: https://leetcode-cn.com/problems/serialize-and-deserialize-bst 英文原文Serialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection li…
原文链接: https://leetcode-cn.com/problems/delete-node-in-a-bst 英文原文Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST. Basically, the deletion can b…
原文链接: 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/4sum-ii 英文原文Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that: 0 <= i, j, k, l < n nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0 Exampl…
原文链接: https://leetcode-cn.com/problems/132-pattern 英文原文Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132…
原文链接: 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/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…
原文链接: https://leetcode-cn.com/problems/can-i-win 英文原文In the "100 game" two players take turns adding, to a running total, any integer from 1 to 10. The player who first causes the running total to reach or exceed 100 wins. What if we change the game …
原文链接: https://leetcode-cn.com/problems/unique-substrings-in-wraparound-string 英文原文We define the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr…
原文链接: https://leetcode-cn.com/problems/validate-ip-address 英文原文Given a string queryIP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of any type. A valid IPv4 address is an IP…
原文链接: https://leetcode-cn.com/problems/ones-and-zeroes 英文原文You are given an array of binary strings strs and two integers m and n. Return the size of the largest subset of strs such that there are at most m 0's and n 1's in the subset. A set x is a s…
原文链接: https://leetcode-cn.com/problems/matchsticks-to-square 英文原文You are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick. You want to use all the matchsticks to make one square. You should not break any sti…
原文链接: https://leetcode-cn.com/problems/total-hamming-distance 英文原文The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given an integer array nums, return the sum of Hamming distances bet…
原文链接: 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/predict-the-winner 英文原文You are given an integer array nums. Two players are playing a game with this array: player 1 and player 2. Player 1 and player 2 take turns, with player 1 starting first. Both players sta…
原文链接: https://leetcode-cn.com/problems/increasing-subsequences 英文原文Given an integer array nums, return all the different possible increasing subsequences of the given array with at least two elements. You may return the answer in any order. The given…
原文链接: https://leetcode-cn.com/problems/target-sum 英文原文You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all…
原文链接: https://leetcode-cn.com/problems/diagonal-traverse 英文原文Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order. Example 1: Input: mat = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,4,7,5,3,6,8,9] Example 2: Inp…
原文链接: https://leetcode-cn.com/problems/next-greater-element-ii 英文原文Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums. The next greater number of …
原文链接: https://leetcode-cn.com/problems/most-frequent-subtree-sum 英文原文Given the root of a binary tree, return the most frequent subtree sum. If there is a tie, return all the values with the highest frequency in any order. The subtree sum of a node is…
原文链接: https://leetcode-cn.com/problems/find-bottom-left-tree-value 英文原文Given the root of a binary tree, return the leftmost value in the last row of the tree. Example 1: Input: root = [2,1,3] Output: 1 Example 2: Input: root = [1,2,3,4,null,5,6,null,…
原文链接: https://leetcode-cn.com/problems/find-largest-value-in-each-tree-row 英文原文Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed). Example 1: Input: root = [1,3,2,5,3,null,9] Output: [1,3,9] Exam…
原文链接: https://leetcode-cn.com/problems/longest-palindromic-subsequence 英文原文Given a string s, find the longest palindromic subsequence's length in s. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements…
原文链接: https://leetcode-cn.com/problems/coin-change-2 英文原文You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the number of combinations that make up tha…
原文链接: 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/continuous-subarray-sum 英文原文Given an integer array nums and an integer k, return true if nums has a continuous subarray of size at least two whose elements sum up to a multiple of k, or false otherwise. An integ…
原文链接: 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 …