原文链接: https://leetcode-cn.com/problems/airplane-seat-assignment-probability 英文原文n passengers board an airplane with exactly n seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of passengers will: Take …
标签详情
动态规划 分类
原文链接: https://leetcode-cn.com/problems/maximum-height-by-stacking-cuboids 英文原文Given n cuboids where the dimensions of the ith cuboid is cuboids[i] = [widthi, lengthi, heighti] (0-indexed). Choose a subset of cuboids and place them on each other. You …
原文链接: https://leetcode-cn.com/problems/maximum-score-words-formed-by-letters 英文原文Given a list of words, list of single letters (might be repeating) and score of every character. Return the maximum score of any valid set of words formed by using the g…
原文链接: 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/number-of-ways-to-stay-in-the-same-place-after-some-steps 英文原文You have a pointer at index 0 in an array of size arrLen. At each step, you can move 1 position to the left, 1 position to the right in the array, or…
原文链接: https://leetcode-cn.com/problems/count-square-submatrices-with-all-ones 英文原文Given a m * n matrix of ones and zeros, return how many square submatrices have all ones. Example 1: Input: matrix = [ [0,1,1,1], [1,1,1,1], [0,1,1,1] ] Output: 15 Expl…
原文链接: https://leetcode-cn.com/problems/palindrome-partitioning-iii 英文原文You are given a string s containing lowercase letters and an integer k. You need to : First, change some characters of s to other lowercase English letters. Then divide s into k n…
原文链接: https://leetcode-cn.com/problems/minimum-insertion-steps-to-make-a-string-palindrome 英文原文Given a string s. In one step you can insert any character at any index of the string. Return the minimum number of steps to make s palindrome. A Palindrom…
原文链接: https://leetcode-cn.com/problems/minimum-distance-to-type-a-word-using-two-fingers 英文原文 You have a keyboard layout as shown above in the X-Y plane, where each English uppercase letter is located at some coordinate. For example, the letter 'A' i…
原文链接: 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 + …
原文链接: https://leetcode-cn.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance 英文原文There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional …
原文链接: https://leetcode-cn.com/problems/minimum-difficulty-of-a-job-schedule 英文原文You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i-th job, you have to finish all the jobs j where 0 <= j < i). You have to finish at…
原文链接: https://leetcode-cn.com/problems/jump-game-v 英文原文Given an array of integers arr and an integer d. In one step you can jump from index i to index: i + x where: i + x < arr.length and 0 < x <= d. i - x where: i - x >= 0 and 0 < x <= d. In additio…
原文链接: https://leetcode-cn.com/problems/maximum-students-taking-exam 英文原文Given a m * n matrix seats that represent seats distributions in a classroom. If a seat is broken, it is denoted by '#' character otherwise it is denoted by a '.' character. Stud…
原文链接: https://leetcode-cn.com/problems/longest-zigzag-path-in-a-binary-tree 英文原文You are given the root of a binary tree. A ZigZag path for a binary tree is defined as follow: Choose any node in the binary tree and a direction (right or left). If the …
原文链接: https://leetcode-cn.com/problems/maximum-sum-bst-in-binary-tree 英文原文Given a binary tree root, return the maximum sum of all keys of any sub-tree which is also a Binary Search Tree (BST). Assume a BST is defined as follows: The left subtree of a…
原文链接: https://leetcode-cn.com/problems/sort-integers-by-the-power-value 英文原文The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps: if x is even then x = x / 2 if x is odd then x = 3 * x + 1…
原文链接: 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/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/count-number-of-teams 英文原文There are n soldiers standing in a line. Each soldier is assigned a unique rating value. You have to form a team of 3 soldiers amongst them under the following rules: Choose 3 soldiers …
原文链接: https://leetcode-cn.com/problems/find-all-good-strings 英文原文Given the strings s1 and s2 of size n and the string evil, return the number of good strings. A good string has size n, it is alphabetically greater than or equal to s1, it is alphabeti…
原文链接: https://leetcode-cn.com/problems/stone-game-iii 英文原文Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue. A…
原文链接: https://leetcode-cn.com/problems/number-of-ways-to-paint-n-3-grid 英文原文You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent c…
原文链接: 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/build-array-where-you-can-find-the-maximum-exactly-k-comparisons 英文原文Given three integers n, m and k. Consider the following algorithm to find the maximum element of an array of positive integers: You should bui…
原文链接: 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/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/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/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…