原文链接: https://leetcode-cn.com/problems/reduce-array-size-to-the-half 英文原文You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum size of the set so that at…
标签详情
贪心 分类
原文链接: https://leetcode-cn.com/problems/maximum-number-of-events-that-can-be-attended 英文原文Given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi. You can attend an event i at any day d wh…
原文链接: https://leetcode-cn.com/problems/cinema-seat-allocation 英文原文 A cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above. Given the array reservedSeats containing th…
原文链接: https://leetcode-cn.com/problems/pizza-with-3n-slices 英文原文There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows: You will pick any pizza slice. Your friend Alice will pick next slice in anti …
原文链接: https://leetcode-cn.com/problems/maximum-performance-of-a-team 英文原文You are given two integers n and k and two integer arrays speed and efficiency both of length n. There are n engineers numbered from 1 to n. speed[i] and efficiency[i] represent…
原文链接: https://leetcode-cn.com/problems/construct-k-palindrome-strings 英文原文Given a string s and an integer k. You should construct k non-empty palindrome strings using all the characters in s. Return True if you can use all the characters in s to cons…
原文链接: https://leetcode-cn.com/problems/reducing-dishes 英文原文A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time. Like-time coefficient of a dish is defined as the time taken to cook that dish i…
原文链接: https://leetcode-cn.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k 英文原文Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times. T…
原文链接: https://leetcode-cn.com/problems/minimum-subsequence-in-non-increasing-order 英文原文Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subsequence. If…
原文链接: https://leetcode-cn.com/problems/check-if-a-string-can-break-another-string 英文原文Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can…
原文链接: https://leetcode-cn.com/problems/max-difference-you-can-get-from-changing-an-integer 英文原文You are given an integer num. You will apply the following steps exactly two times: Pick a digit x (0 <= x <= 9). Pick another digit y (0 <= y <= 9). The d…
原文链接: https://leetcode-cn.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts 英文原文You are given a rectangular cake of size h x w and two arrays of integers horizontalCuts and verticalCuts where: horizontalCuts[i] is the di…
原文链接: https://leetcode-cn.com/problems/least-number-of-unique-integers-after-k-removals 英文原文Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements. Example 1: Input: arr = [5,5,4], …
原文链接: https://leetcode-cn.com/problems/avoid-flood-in-the-city 英文原文Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, the nth lake becomes full of water. If it rains over a lake whic…
原文链接: https://leetcode-cn.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves 英文原文Given an array nums, you are allowed to choose one element of nums and change it by any value in one move. Return the minimum difference b…
原文链接: https://leetcode-cn.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits 英文原文Given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the i…
原文链接: https://leetcode-cn.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array 英文原文Given an array of positive integers target and an array initial of same size with all zeros. Return the minimum number of operations to form a…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-non-overlapping-substrings 英文原文Given a string s of lowercase letters, you need to find the maximum number of non-empty substrings of s that meet the following conditions: The substrings do not …
原文链接: https://leetcode-cn.com/problems/minimum-insertions-to-balance-a-parentheses-string 英文原文Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if: Any left parenthesis '(' must have a correspon…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target 英文原文Given an array nums and an integer target. Return the maximum number of non-empty non-overlapping subarrays such that the sum of values in e…
原文链接: https://leetcode-cn.com/problems/bulb-switcher-iv 英文原文There is a room with n bulbs, numbered from 0 to n - 1, arranged in a row from left to right. Initially, all the bulbs are turned off. Your task is to obtain the configuration represented by…
原文链接: https://leetcode-cn.com/problems/minimum-swaps-to-arrange-a-binary-grid 英文原文Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them. A grid is said to be valid if all the cells above the main diagonal …
原文链接: https://leetcode-cn.com/problems/get-the-maximum-score 英文原文You are given two sorted arrays of distinct integers nums1 and nums2. A valid path is defined as follows: Choose array nums1 or nums2 to traverse (from index-0). Traverse the current ar…
原文链接: https://leetcode-cn.com/problems/minimum-numbers-of-function-calls-to-make-target-array 英文原文 Your task is to form an integer array nums from an initial array of zeros arr that is the same size as nums. Return the minimum number of function call…
原文链接: https://leetcode-cn.com/problems/maximum-length-of-subarray-with-positive-product 英文原文Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive. A subarray of an array is a consecut…
原文链接: https://leetcode-cn.com/problems/maximum-sum-obtained-of-any-permutation 英文原文We have an array of integers, nums, and an array of requests where requests[i] = [starti, endi]. The ith request asks for the sum of nums[starti] + nums[starti + 1] + …
原文链接: https://leetcode-cn.com/problems/minimum-deletion-cost-to-avoid-repeating-letters 英文原文Given a string s and an array of integers cost where cost[i] is the cost of deleting the ith character in s. Return the minimum cost of deletions such that th…
原文链接: https://leetcode-cn.com/problems/check-if-string-is-transformable-with-substring-sort-operations 英文原文Given two strings s and t, you want to transform string s into string t using the following operation any number of times: Choose a non-empty s…
原文链接: https://leetcode-cn.com/problems/find-servers-that-handled-most-number-of-requests 英文原文You have k servers numbered from 0 to k-1 that are being used to handle multiple requests simultaneously. Each server has infinite computational capacity but…
原文链接: https://leetcode-cn.com/problems/find-valid-matrix-given-row-and-column-sums 英文原文You are given two arrays rowSum and colSum of non-negative integers where rowSum[i] is the sum of the elements in the ith row and colSum[j] is the sum of the eleme…