原文链接: 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/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/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/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/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/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/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/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/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/smallest-subsequence-of-distinct-characters 英文原文Given a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once. Example 1: Input: s = "bcabc"…
原文链接: https://leetcode-cn.com/problems/largest-values-from-labels 英文原文There is a set of n items. You are given two integer arrays values and labels where the value and the label of the ith element are values[i] and labels[i] respectively. You are als…
原文链接: https://leetcode-cn.com/problems/minimum-cost-tree-from-leaf-values 英文原文Given an array arr of positive integers, consider all binary trees such that: Each node has either 0 or 2 children; The values of arr correspond to the values of each leaf …
原文链接: https://leetcode-cn.com/problems/decrease-elements-to-make-array-zigzag 英文原文Given an array nums of integers, a move consists of choosing any element and decreasing it by 1. An array A is a zigzag array if either: Every even-indexed element is g…
原文链接: https://leetcode-cn.com/problems/longest-chunked-palindrome-decomposition 英文原文You are given a string text. You should split it to k substrings (subtext1, subtext2, ..., subtextk) such that: subtexti is a non-empty string. The concatenation of a…
原文链接: https://leetcode-cn.com/problems/break-a-palindrome 英文原文Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and tha…
原文链接: https://leetcode-cn.com/problems/reverse-subarray-to-maximize-array-value 英文原文You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1. You are allowed to sel…
原文链接: https://leetcode-cn.com/problems/rank-transform-of-a-matrix 英文原文Given an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col]. The rank is an integer that represents how large an element is compared to…
原文链接: https://leetcode-cn.com/problems/largest-multiple-of-three 英文原文Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. If there is no answer return an empt…
原文链接: https://leetcode-cn.com/problems/balance-a-binary-search-tree 英文原文Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them. A binary search tree…
原文链接: https://leetcode-cn.com/problems/longest-happy-string 英文原文A string is called happy if it does not have any of the strings 'aaa', 'bbb' or 'ccc' as a substring. Given three integers a, b and c, return any string s, which satisfies following cond…
原文链接: https://leetcode-cn.com/problems/minimum-cost-to-move-chips-to-the-same-position 英文原文We have n chips, where the position of the ith chip is position[i]. We need to move all the chips to the same position. In one step, we can change the position…
原文链接: https://leetcode-cn.com/problems/split-a-string-in-balanced-strings 英文原文Balanced strings are those that have an equal quantity of 'L' and 'R' characters. Given a balanced string s, split it in the maximum amount of balanced strings. Return the …
原文链接: https://leetcode-cn.com/problems/minimum-swaps-to-make-strings-equal 英文原文You are given two strings s1 and s2 of equal length consisting of letters "x" and "y" only. Your task is to make these two strings equal to each other. You can swap any tw…
原文链接: https://leetcode-cn.com/problems/reconstruct-a-2-row-binary-matrix 英文原文Given the following details of a matrix with n columns and 2 rows : The matrix is a binary matrix, which means each element in the matrix can be 0 or 1. The sum of elements …
原文链接: https://leetcode-cn.com/problems/greatest-sum-divisible-by-three 英文原文Given an array nums of integers, we need to find the maximum possible sum of elements of the array such that it is divisible by three. Example 1: Input: nums = [3,6,5,1,8] Out…
原文链接: https://leetcode-cn.com/problems/divide-array-in-sets-of-k-consecutive-numbers 英文原文Given an array of integers nums and a positive integer k, find whether it is possible to divide this array into sets of k consecutive numbers. Return true if it …
原文链接: https://leetcode-cn.com/problems/maximum-69-number 英文原文Given a positive integer num consisting only of digits 6 and 9. Return the maximum number you can get by changing at most one digit (6 becomes 9, and 9 becomes 6). Example 1: Input: num = 9…
原文链接: https://leetcode-cn.com/problems/minimum-number-of-taps-to-open-to-water-a-garden 英文原文There is a one-dimensional garden on the x-axis. The garden starts at the point 0 and ends at the point n. (i.e The length of the garden is n). There are n + …