原文链接: https://leetcode-cn.com/problems/number-of-ways-to-wear-different-hats-to-each-other 英文原文There are n people and 40 types of hats labeled from 1 to 40. Given a list of list of integers hats, where hats[i] is a list of all hats preferred by the i…
标签详情
数组 分类
原文链接: https://leetcode-cn.com/problems/display-table-of-food-orders-in-a-restaurant 英文原文Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,foodItemi] w…
原文链接: https://leetcode-cn.com/problems/maximum-points-you-can-obtain-from-cards 英文原文There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints. In one step, you ca…
原文链接: https://leetcode-cn.com/problems/diagonal-traverse-ii 英文原文Given a list of lists of integers, nums, return all elements of nums in diagonal order as shown in the below images. Example 1: Input: nums = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,4,2,7,5…
原文链接: https://leetcode-cn.com/problems/form-largest-integer-with-digits-that-add-up-to-target 英文原文Given an array of integers cost and an integer target. Return the maximum integer you can paint under the following rules: The cost of painting a digit …
原文链接: https://leetcode-cn.com/problems/check-if-all-1s-are-at-least-length-k-places-away 英文原文Given an array nums of 0s and 1s and an integer k, return True if all 1's are at least k places away from each other, otherwise return False. Example 1: Inpu…
原文链接: https://leetcode-cn.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit 英文原文Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute diffe…
原文链接: https://leetcode-cn.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows 英文原文You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing order. You are allowed to choose exactly 1 element fro…
原文链接: https://leetcode-cn.com/problems/build-an-array-with-stack-operations 英文原文Given an array target and an integer n. In each iteration, you will read a number from list = {1,2,3..., n}. Build the target array using the following operations: Push: …
原文链接: https://leetcode-cn.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor 英文原文Given an array of integers arr. We want to select three indices i, j and k where (0 <= i < j <= k < arr.length). Let's define a and b as follows: a = arr[…
原文链接: https://leetcode-cn.com/problems/number-of-ways-of-cutting-a-pizza 英文原文Given a rectangular pizza represented as a rows x cols matrix containing the following characters: 'A' (an apple) and '.' (empty cell) and given the integer k. You have to c…
原文链接: https://leetcode-cn.com/problems/make-two-arrays-equal-by-reversing-sub-arrays 英文原文Given two integer arrays of equal length target and arr. In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any n…
原文链接: https://leetcode-cn.com/problems/cherry-pickup-ii 英文原文Given a rows x cols matrix grid representing a field of cherries. Each cell in grid represents the number of cherries that you can collect. You have two robots that can collect cherries for …
原文链接: https://leetcode-cn.com/problems/number-of-students-doing-homework-at-a-given-time 英文原文Given two integer arrays startTime and endTime and given an integer queryTime. The ith student started doing their homework at the time startTime[i] and fini…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard 英文原文You have a very large square wall and a circular dartboard placed on the wall. You have been challenged to throw darts into the board blindfolded. Darts…
原文链接: https://leetcode-cn.com/problems/max-dot-product-of-two-subsequences 英文原文Given two arrays nums1 and nums2. Return the maximum dot product between non-empty subsequences of nums1 and nums2 with the same length. A subsequence of a array is a new …
原文链接: https://leetcode-cn.com/problems/allocate-mailboxes 英文原文Given the array houses and an integer k. where houses[i] is the location of the ith house along a street, your task is to allocate k mailboxes in the street. Return the minimum total dista…
原文链接: https://leetcode-cn.com/problems/final-prices-with-a-special-discount-in-a-shop 英文原文Given the array prices where prices[i] is the price of the ith item in a shop. There is a special discount for items in the shop, if you buy the ith item, then …
原文链接: https://leetcode-cn.com/problems/subrectangle-queries 英文原文Implement the class SubrectangleQueries which receives a rows x cols rectangle as a matrix of integers in the constructor and supports two methods: 1. updateSubrectangle(int row1, int co…
原文链接: https://leetcode-cn.com/problems/maximum-product-of-two-elements-in-an-array 英文原文Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1). Example 1: Inpu…
原文链接: 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/shuffle-the-array 英文原文Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn]. Return the array in the form [x1,y1,x2,y2,...,xn,yn]. Example 1: Input: nums = [2,5,1,3,4,7], n = 3 O…
原文链接: https://leetcode-cn.com/problems/the-k-strongest-values-in-an-array 英文原文Given an array of integers arr and an integer k. A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array…
原文链接: https://leetcode-cn.com/problems/design-browser-history 英文原文You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Imp…
原文链接: https://leetcode-cn.com/problems/paint-house-iii 英文原文There is a row of m houses in a small city, each house must be painted with one of the n colors (labeled from 1 to n), some houses that have been painted last summer should not be painted aga…
原文链接: https://leetcode-cn.com/problems/running-sum-of-1d-array 英文原文Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nums. Example 1: Input: nums = [1,2,3,4] Output: [1,…
原文链接: 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/minimum-number-of-days-to-make-m-bouquets 英文原文Given an integer array bloomDay, an integer m and an integer k. We need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden. Th…
原文链接: 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/range-sum-of-sorted-subarray-sums 英文原文You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreas…