原文链接: https://leetcode-cn.com/problems/fruit-into-baskets 英文原文You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] is the type of fruit the ith …
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/smallest-range-ii 英文原文You are given an integer array nums and an integer k. For each index i where 0 <= i < nums.length, change nums[i] to be either nums[i] + k or nums[i] - k. The score of nums is the differenc…
原文链接: https://leetcode-cn.com/problems/snakes-and-ladders 英文原文You are given an n x n integer matrix board where the cells are labeled from 1 to n2 in a Boustrophedon style starting from the bottom left of the board (i.e. board[n - 1][0]) and alternat…
原文链接: https://leetcode-cn.com/problems/online-election 英文原文You are given two integer arrays persons and times. In an election, the ith vote was cast for persons[i] at time times[i]. For each query at a time t, find the person that was leading the ele…
原文链接: https://leetcode-cn.com/problems/sort-an-array 英文原文Given an array of integers nums, sort the array in ascending order. Example 1: Input: nums = [5,2,3,1] Output: [1,2,3,5] Example 2: Input: nums = [5,1,1,2,0,0] Output: [0,0,1,1,2,5] Constraints…
原文链接: https://leetcode-cn.com/problems/partition-array-into-disjoint-intervals 英文原文Given an integer array nums, partition it into two (contiguous) subarrays left and right so that: Every element in left is less than or equal to every element in right…
原文链接: https://leetcode-cn.com/problems/word-subsets 英文原文You are given two string arrays words1 and words2. A string b is a subset of string a if every letter in b occurs in a including multiplicity. For example, "wrr" is a subset of "warrior" but is …
原文链接: https://leetcode-cn.com/problems/complete-binary-tree-inserter 英文原文A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. Design an algorithm to i…
原文链接: https://leetcode-cn.com/problems/minimum-add-to-make-parentheses-valid 英文原文A parentheses string is valid if and only if: It is the empty string, It can be written as AB (A concatenated with B), where A and B are valid strings, or It can be writ…
原文链接: 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/flip-string-to-monotone-increasing 英文原文A binary string is monotone increasing if it consists of some number of 0's (possibly none), followed by some number of 1's (also possibly none). You are given a binary str…
原文链接: https://leetcode-cn.com/problems/binary-subarrays-with-sum 英文原文Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal. A subarray is a contiguous part of the array. Example 1: Input: nums = [1,0,…
原文链接: https://leetcode-cn.com/problems/minimum-falling-path-sum 英文原文Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix. A falling path starts at any element in the first row and chooses the element in t…
原文链接: https://leetcode-cn.com/problems/beautiful-array 英文原文An array nums of length n is beautiful if: nums is a permutation of the integers in the range [1, n]. For every 0 <= i < j < n, there is no index k with i < k < j where 2 * nums[k] == nums[i]…
原文链接: https://leetcode-cn.com/problems/shortest-bridge 英文原文You are given an n x n binary matrix grid where 1 represents land and 0 represents water. An island is a 4-directionally connected group of 1's not connected to any other 1's. There are exact…
原文链接: https://leetcode-cn.com/problems/knight-dialer 英文原文The chess knight has a unique movement, it may move two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming the shape of an …
原文链接: https://leetcode-cn.com/problems/minimum-area-rectangle 英文原文You are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of a rectangle formed from these points, with sides parallel to the X and Y…
原文链接: https://leetcode-cn.com/problems/minimum-increment-to-make-array-unique 英文原文You are given an integer array nums. In one move, you can pick an index i where 0 <= i < nums.length and increment nums[i] by 1. Return the minimum number of moves to m…
原文链接: https://leetcode-cn.com/problems/validate-stack-sequences 英文原文Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop operations on an initially empty st…
原文链接: https://leetcode-cn.com/problems/most-stones-removed-with-same-row-or-column 英文原文On a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it shares either th…
原文链接: https://leetcode-cn.com/problems/largest-time-for-given-digits 英文原文Given an array arr of 4 digits, find the latest 24-hour time that can be made using each digit exactly once. 24-hour times are formatted as "HH:MM", where HH is between 00 and 2…
原文链接: 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/reveal-cards-in-increasing-order 英文原文You are given an integer array deck. There is a deck of cards where every card has a unique integer. The integer on the ith card is deck[i]. You can order the deck in any ord…
原文链接: https://leetcode-cn.com/problems/array-of-doubled-pairs 英文原文Given an integer array of even length arr, return true if it is possible to reorder arr such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < len(arr) / 2, or false otherwise. E…
原文链接: https://leetcode-cn.com/problems/delete-columns-to-make-sorted-ii 英文原文You are given an array of n strings strs, all of the same length. We may choose any deletion indices, and we delete all the characters in those indices for each string. For e…
原文链接: https://leetcode-cn.com/problems/prison-cells-after-n-days 英文原文There are 8 prison cells in a row and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to the following rules: If a cell ha…
原文链接: https://leetcode-cn.com/problems/check-completeness-of-a-binary-tree 英文原文Given the root of a binary tree, determine if it is a complete binary tree. In a complete binary tree, every level, except possibly the last, is completely filled, and all…
原文链接: https://leetcode-cn.com/problems/regions-cut-by-slashes 英文原文An n x n grid is composed of 1 x 1 squares where each 1 x 1 square consists of a '/', '\', or blank space ' '. These characters divide the square into contiguous regions. Given the gri…
原文链接: https://leetcode-cn.com/problems/minimum-area-rectangle-ii 英文原文You are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of any rectangle formed from these points, with sides not necessarily pa…
原文链接: https://leetcode-cn.com/problems/vowel-spellchecker 英文原文Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word. For a given query word, the spell checker handles two categories of spelling mistakes:…