原文链接: https://leetcode-cn.com/problems/minimum-domino-rotations-for-equal-row 英文原文In a row of dominoes, tops[i] and bottoms[i] represent the top and bottom halves of the ith domino. (A domino is a tile with two numbers from 1 to 6 - one on each half …
标签详情
数组 分类
原文链接: https://leetcode-cn.com/problems/construct-binary-search-tree-from-preorder-traversal 英文原文Given an array of integers preorder, which represents the preorder traversal of a BST (i.e., binary search tree), construct the tree and return its root. …
原文链接: https://leetcode-cn.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 英文原文You are given a list of songs where the ith song has a duration of time[i] seconds. Return the number of pairs of songs for which their total duration in s…
原文链接: https://leetcode-cn.com/problems/capacity-to-ship-packages-within-d-days 英文原文A conveyor belt has packages that must be shipped from one port to another within days days. The ith package on the conveyor belt has a weight of weights[i]. Each day,…
原文链接: 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/best-sightseeing-pair 英文原文You are given an integer array values where values[i] represents the value of the ith sightseeing spot. Two sightseeing spots i and j have a distance j - i between them. The score of a …
原文链接: 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/next-greater-node-in-linked-list 英文原文You are given the head of a linked list with n nodes. For each node in the list, find the value of the next greater node. That is, for each node, find the value of the first …
原文链接: https://leetcode-cn.com/problems/number-of-enclaves 英文原文You are given an m x n binary matrix grid, where 0 represents a sea cell and 1 represents a land cell. A move consists of walking from one land cell to another adjacent (4-directionally) l…
原文链接: https://leetcode-cn.com/problems/video-stitching 英文原文You are given a series of video clips from a sporting event that lasted time seconds. These video clips can be overlapping with each other and have varying lengths. Each video clip is describ…
原文链接: https://leetcode-cn.com/problems/longest-arithmetic-subsequence 英文原文Given an array nums of integers, return the length of the longest arithmetic subsequence in nums. Recall that a subsequence of an array nums is a list nums[i1], nums[i2], ..., …
原文链接: 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/two-city-scheduling 英文原文A company is planning to interview 2n people. Given the array costs where costs[i] = [aCosti, bCosti], the cost of flying the ith person to city a is aCosti, and the cost of flying the it…
原文链接: https://leetcode-cn.com/problems/stream-of-characters 英文原文Design an algorithm that accepts a stream of characters and checks if a suffix of these characters is a string of a given array of strings words. For example, if words = ["abc", "xyz"] a…
原文链接: https://leetcode-cn.com/problems/maximum-sum-of-two-non-overlapping-subarrays 英文原文Given an integer array nums and two integers firstLen and secondLen, return the maximum sum of elements in two non-overlapping subarrays with lengths firstLen and…
原文链接: https://leetcode-cn.com/problems/coloring-a-border 英文原文You are given an m x n integer matrix grid, and three integers row, col, and color. Each value in the grid represents the color of the grid square at that location. Two squares belong to th…
原文链接: https://leetcode-cn.com/problems/uncrossed-lines 英文原文You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines. We may draw connecting lines: a stra…
原文链接: https://leetcode-cn.com/problems/escape-a-large-maze 英文原文There is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are (x, y). We start at the source = [sx, sy] square and want to reach the target = [tx, ty]…
原文链接: https://leetcode-cn.com/problems/minimum-score-triangulation-of-polygon 英文原文You have a convex n-sided polygon where each vertex has an integer value. You are given an integer array values where values[i] is the value of the ith vertex (i.e., cl…
原文链接: 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…
原文链接: https://leetcode-cn.com/problems/moving-stones-until-consecutive-ii 英文原文There are some stones in different positions on the X-axis. You are given an integer array stones, the positions of the stones. Call a stone an endpoint stone if it has the…
原文链接: https://leetcode-cn.com/problems/as-far-from-land-as-possible 英文原文Given an n x n grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized…
原文链接: https://leetcode-cn.com/problems/partition-array-for-maximum-sum 英文原文Given an integer array arr, partition the array into (contiguous) subarrays of length at most k. After partitioning, each subarray has their values changed to become the maxim…
原文链接: https://leetcode-cn.com/problems/last-stone-weight 英文原文You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose the heaviest two stones and smash th…
原文链接: https://leetcode-cn.com/problems/longest-string-chain 英文原文You are given an array of words where each word consists of lowercase English letters. wordA is a predecessor of wordB if and only if we can insert exactly one letter anywhere in wordA w…
原文链接: https://leetcode-cn.com/problems/last-stone-weight-ii 英文原文You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose any two stones and smash them tog…
原文链接: https://leetcode-cn.com/problems/grumpy-bookstore-owner 英文原文There is a bookstore owner that has a store open for n minutes. Every minute, some number of customers enter the store. You are given an integer array customers of length n where custo…
原文链接: https://leetcode-cn.com/problems/previous-permutation-with-one-swap 英文原文Given an array of positive integers arr (not necessarily distinct), return the lexicographically largest permutation that is smaller than arr, that can be made with exactly…
原文链接: https://leetcode-cn.com/problems/distant-barcodes 英文原文In a warehouse, there is a row of barcodes, where the ith barcode is barcodes[i]. Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guar…
原文链接: https://leetcode-cn.com/problems/number-of-submatrices-that-sum-to-target 英文原文Given a matrix and a target, return the number of non-empty submatrices that sum to target. A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <=…