原文链接: https://leetcode-cn.com/problems/check-if-all-1s-are-at-least-length-k-places-away 英文原文Given an array nums of 0s and 1s and an integer k, return True if all 1's are at least k places away from each other, otherwise return False. Example 1: Inpu…
分类详情
简单 分类
原文链接: https://leetcode-cn.com/problems/build-an-array-with-stack-operations 英文原文Given an array target and an integer n. In each iteration, you will read a number from list = {1,2,3..., n}. Build the target array using the following operations: Push: …
原文链接: https://leetcode-cn.com/problems/make-two-arrays-equal-by-reversing-sub-arrays 英文原文Given two integer arrays of equal length target and arr. In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any n…
原文链接: https://leetcode-cn.com/problems/number-of-students-doing-homework-at-a-given-time 英文原文Given two integer arrays startTime and endTime and given an integer queryTime. The ith student started doing their homework at the time startTime[i] and fini…
原文链接: https://leetcode-cn.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence 英文原文Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentenc…
原文链接: https://leetcode-cn.com/problems/final-prices-with-a-special-discount-in-a-shop 英文原文Given the array prices where prices[i] is the price of the ith item in a shop. There is a special discount for items in the shop, if you buy the ith item, then …
原文链接: https://leetcode-cn.com/problems/maximum-product-of-two-elements-in-an-array 英文原文Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1). Example 1: Inpu…
原文链接: https://leetcode-cn.com/problems/shuffle-the-array 英文原文Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn]. Return the array in the form [x1,y1,x2,y2,...,xn,yn]. Example 1: Input: nums = [2,5,1,3,4,7], n = 3 O…
原文链接: https://leetcode-cn.com/problems/running-sum-of-1d-array 英文原文Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nums. Example 1: Input: nums = [1,2,3,4] Output: [1,…
原文链接: https://leetcode-cn.com/problems/xor-operation-in-an-array 英文原文Given an integer n and an integer start. Define an array nums where nums[i] = start + 2*i (0-indexed) and n == nums.length. Return the bitwise XOR of all elements of nums. Example 1…
原文链接: https://leetcode-cn.com/problems/path-crossing 英文原文Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on …
原文链接: https://leetcode-cn.com/problems/can-make-arithmetic-progression-from-sequence 英文原文A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same. Given an array of numbers arr, retu…
原文链接: https://leetcode-cn.com/problems/count-odd-numbers-in-an-interval-range 英文原文Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive). Example 1: Input: low = 3, high = 7 Output: 3 Explanatio…
原文链接: https://leetcode-cn.com/problems/number-of-good-pairs 英文原文Given an array of integers nums, return the number of good pairs. A pair (i, j) is called good if nums[i] == nums[j] and i < j. Example 1: Input: nums = [1,2,3,1,1,3] Output: 4 Explanati…
原文链接: https://leetcode-cn.com/problems/water-bottles 英文原文Given numBottles full water bottles, you can exchange numExchange empty water bottles for one full water bottle. The operation of drinking a full water bottle turns it into an empty bottle. Ret…
原文链接: https://leetcode-cn.com/problems/kth-missing-positive-number 英文原文Given an array arr of positive integers sorted in a strictly increasing order, and an integer k. Find the kth positive integer that is missing from this array. Example 1: Input: a…
原文链接: https://leetcode-cn.com/problems/shuffle-string 英文原文Given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string. Return t…
原文链接: https://leetcode-cn.com/problems/thousand-separator 英文原文Given an integer n, add a dot (".") as the thousands separator and return it in string format. Example 1: Input: n = 987 Output: "987" Example 2: Input: n = 1234 Output: "1.234" Example 3:…
原文链接: https://leetcode-cn.com/problems/make-the-string-great 英文原文Given a string s of lower and upper case English letters. A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where: 0 <= i <= s.length - 2 s[i] is a …
原文链接: https://leetcode-cn.com/problems/matrix-diagonal-sum 英文原文Given a square matrix mat, return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are…
原文链接: https://leetcode-cn.com/problems/most-visited-sector-in-a-circular-track 英文原文Given an integer n and an integer array rounds. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the ma…
原文链接: https://leetcode-cn.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times 英文原文Given an array of positive integers arr, find a pattern of length m that is repeated k or more times. A pattern is a subarray (consecutive sub-sequence) th…
原文链接: https://leetcode-cn.com/problems/sum-of-all-odd-length-subarrays 英文原文Given an array of positive integers arr, calculate the sum of all possible odd-length subarrays. A subarray is a contiguous subsequence of the array. Return the sum of all odd…
原文链接: https://leetcode-cn.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters 英文原文Given a string s containing only lowercase English letters and the '?' character, convert all the '?' characters into lowercase letters such that the f…
原文链接: https://leetcode-cn.com/problems/special-positions-in-a-binary-matrix 英文原文Given a rows x cols matrix mat, where mat[i][j] is either 0 or 1, return the number of special positions in mat. A position (i,j) is called special if mat[i][j] == 1 and …
原文链接: https://leetcode-cn.com/problems/design-parking-system 英文原文Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size. Implement the ParkingSy…
原文链接: https://leetcode-cn.com/problems/rearrange-spaces-between-words 英文原文You are given a string text of words that are placed among some number of spaces. Each word consists of one or more lowercase English letters and are separated by at least one …
原文链接: https://leetcode-cn.com/problems/crawler-log-folder 英文原文The Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: "../" : Move to the parent folder of the current folder. (I…
原文链接: https://leetcode-cn.com/problems/special-array-with-x-elements-greater-than-or-equal-x 英文原文You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums…
原文链接: https://leetcode-cn.com/problems/maximum-nesting-depth-of-the-parentheses 英文原文A string is a valid parentheses string (denoted VPS) if it meets one of the following: It is an empty string "", or a single character not equal to "(" or ")", It can…