原文链接: 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/smallest-range-i 英文原文You are given an integer array nums and an integer k. In one operation, you can choose any index i where 0 <= i < nums.length and change nums[i] to nums[i] + x where x is an integer from the…
原文链接: https://leetcode-cn.com/problems/x-of-a-kind-in-a-deck-of-cards 英文原文In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more gr…
原文链接: 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/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/number-of-recent-calls 英文原文You have a RecentCounter class which counts the number of recent requests within a certain time frame. Implement the RecentCounter class: RecentCounter() Initializes the counter with z…
原文链接: https://leetcode-cn.com/problems/reorder-data-in-log-files 英文原文You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: Letter-logs: All words (except th…
原文链接: https://leetcode-cn.com/problems/range-sum-of-bst 英文原文Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high]. Example 1: Input: root = [10…
原文链接: https://leetcode-cn.com/problems/valid-mountain-array 英文原文Given an array of integers arr, return true if and only if it is a valid mountain array. Recall that arr is a mountain array if and only if: arr.length >= 3 There exists some i with 0 < …
原文链接: 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/delete-columns-to-make-sorted 英文原文You are given an array of n strings strs, all of the same length. The strings can be arranged such that there is one on each line, making a grid. For example, strs = ["abc", "bc…
原文链接: https://leetcode-cn.com/problems/verifying-an-alien-dictionary 英文原文In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letter…
原文链接: https://leetcode-cn.com/problems/n-repeated-element-in-size-2n-array 英文原文You are given an integer array nums with the following properties: nums.length == 2 * n. nums contains n + 1 unique elements. Exactly one element of nums is repeated n tim…
原文链接: https://leetcode-cn.com/problems/univalued-binary-tree 英文原文A binary tree is uni-valued if every node in the tree has the same value. Given the root of a binary tree, return true if the given tree is uni-valued, or false otherwise. Example 1: In…
原文链接: https://leetcode-cn.com/problems/largest-perimeter-triangle 英文原文Given an integer array nums, return the largest perimeter of a triangle with a non-zero area, formed from three of these lengths. If it is impossible to form any triangle of a non-…
原文链接: 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/add-to-array-form-of-integer 英文原文The array-form of an integer num is an array representing its digits in left to right order. For example, for num = 1321, the array form is [1,3,2,1]. Given num, the array-form o…
原文链接: https://leetcode-cn.com/problems/cousins-in-binary-tree 英文原文Given the root of a binary tree with unique values and the values of two different nodes of the tree x and y, return true if the nodes corresponding to the values x and y in the tree a…
原文链接: https://leetcode-cn.com/problems/find-the-town-judge 英文原文In a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town judge trusts nobody. Ever…
原文链接: https://leetcode-cn.com/problems/available-captures-for-rook 英文原文On an 8 x 8 chessboard, there is exactly one white rook 'R' and some number of white bishops 'B', black pawns 'p', and empty squares '.'. When the rook moves, it chooses one of fo…
原文链接: https://leetcode-cn.com/problems/find-common-characters 英文原文Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the answer in any order. Example 1: In…
原文链接: https://leetcode-cn.com/problems/complement-of-base-10-integer 英文原文The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. For example, The integer 5 is "101" in …
原文链接: https://leetcode-cn.com/problems/partition-array-into-three-parts-with-equal-sum 英文原文Given an array of integers arr, return true if we can partition the array into three non-empty parts with equal sums. Formally, we can partition the array if w…
原文链接: https://leetcode-cn.com/problems/binary-prefix-divisible-by-5 英文原文You are given a binary array nums (0-indexed). We define xi as the number whose binary representation is the subarray nums[0..i] (from most-significant-bit to least-significant-b…
原文链接: https://leetcode-cn.com/problems/remove-outermost-parentheses 英文原文A valid parentheses string is either empty "", "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, "", "()",…
原文链接: https://leetcode-cn.com/problems/sum-of-root-to-leaf-binary-numbers 英文原文You are given the root of a binary tree where each node has a value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit. For ex…
原文链接: https://leetcode-cn.com/problems/divisor-game 英文原文Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number n on the chalkboard. On each player's turn, that player makes a move consisting of: Choosing any …
原文链接: https://leetcode-cn.com/problems/matrix-cells-in-distance-order 英文原文You are given four integers row, cols, rCenter, and cCenter. There is a rows x cols matrix and you are on the cell with the coordinates (rCenter, cCenter). Return the coordinat…
原文链接: https://leetcode-cn.com/problems/find-words-that-can-be-formed-by-characters 英文原文You are given an array of strings words and a string chars. A string is good if it can be formed by characters from chars (each character can only be used once). R…