原文链接: https://leetcode-cn.com/problems/numbers-with-same-consecutive-differences 英文原文Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k. Note that every number in the answer must n…
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/pancake-sorting 英文原文Given an array of integers arr, sort the array by performing a series of pancake flips. In one pancake flip we do the following steps: Choose an integer k where 1 <= k <= arr.length. Reverse …
原文链接: https://leetcode-cn.com/problems/powerful-integers 英文原文Given three integers x, y, and bound, return a list of all the powerful integers that have a value less than or equal to bound. An integer is powerful if it can be represented as xi + yj fo…
原文链接: https://leetcode-cn.com/problems/flip-binary-tree-to-match-preorder-traversal 英文原文You are given the root of a binary tree with n nodes, where each node is uniquely assigned a value from 1 to n. You are also given a sequence of n values voyage, …
原文链接: https://leetcode-cn.com/problems/k-closest-points-to-origin 英文原文Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0). The distance between two…
原文链接: https://leetcode-cn.com/problems/subarray-sums-divisible-by-k 英文原文Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k. A subarray is a contiguous part of an array. Example 1: Inp…
原文链接: https://leetcode-cn.com/problems/longest-turbulent-subarray 英文原文Given an integer array arr, return the length of a maximum size turbulent subarray of arr. A subarray is turbulent if the comparison sign flips between each adjacent pair of elemen…
原文链接: https://leetcode-cn.com/problems/distribute-coins-in-binary-tree 英文原文You are given the root of a binary tree with n nodes where each node in the tree has node.val coins. There are n coins in total throughout the whole tree. In one move, we may …
原文链接: https://leetcode-cn.com/problems/time-based-key-value-store 英文原文Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp. Implement…
原文链接: https://leetcode-cn.com/problems/string-without-aaa-or-bbb 英文原文Given two integers a and b, return any string s such that: s has length a + b and contains exactly a 'a' letters, and exactly b 'b' letters, The substring 'aaa' does not occur in s,…
原文链接: https://leetcode-cn.com/problems/sum-of-even-numbers-after-queries 英文原文You are given an integer array nums and an array queries where queries[i] = [vali, indexi]. For each query i, first, apply nums[indexi] = nums[indexi] + vali, then print the…
原文链接: https://leetcode-cn.com/problems/interval-list-intersections 英文原文You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each list of intervals is pairwise d…
原文链接: https://leetcode-cn.com/problems/smallest-string-starting-from-leaf 英文原文You are given the root of a binary tree where each node has a value in the range [0, 25] representing the letters 'a' to 'z'. Return the lexicographically smallest string t…
原文链接: https://leetcode-cn.com/problems/satisfiability-of-equality-equations 英文原文You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different fo…
原文链接: https://leetcode-cn.com/problems/broken-calculator 英文原文There is a broken calculator that has the integer startValue on its display initially. In one operation, you can: multiply the number on display by 2, or subtract 1 from the number on displ…
原文链接: https://leetcode-cn.com/problems/maximum-binary-tree-ii 英文原文A maximum tree is a tree where every node has a value greater than any other value in its subtree. You are given the root of a maximum binary tree and an integer val. Just as in the pr…
原文链接: https://leetcode-cn.com/problems/check-if-word-is-valid-after-substitutions 英文原文Given a string s, determine if it is valid. A string s is valid if, starting with an empty string t = "", you can transform t into s after performing the following …
原文链接: https://leetcode-cn.com/problems/max-consecutive-ones-iii 英文原文Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's. Example 1: Input: nums = [1,1,1,0,0,0,1,1,1,1,0],…
原文链接: https://leetcode-cn.com/problems/clumsy-factorial 英文原文The factorial of a positive integer n is the product of all positive integers less than or equal to n. For example, factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1. We make a clumsy f…
原文链接: 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/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/smallest-integer-divisible-by-k 英文原文Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1. Return the length of…
原文链接: https://leetcode-cn.com/problems/binary-string-with-substrings-representing-1-to-n 英文原文Given a binary string s and a positive integer n, return true if the binary representation of all the integers in the range [1, n] are substrings of s, or fa…
原文链接: https://leetcode-cn.com/problems/convert-to-base-2 英文原文Given an integer n, return a binary string representing its representation in base -2. Note that the returned string should not have leading zeros unless the string is "0". Example 1: Input…
原文链接: 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…