Given an array umbrella of size N. umbrella[i] means the number of people that it can cover. Find the minimum number of umbrella needed to cover exactly amount person. If not possible, return -1.
constraint:
Given two arrays A and B of same length N.
You can select a subset of A and increment them by 1. You can only do this at most once.
You can also freely re-arrange elements in A.
Return True if A can be made into B, False otherwise.
Constraint
1 <= N <= 1e6
-1e6 <= A[i] <= 1e6
-1e6 <= B[i] <= 1e6
Function sigature
bool func(string A, string B){
// implement your solution here.
}
Given a grid. There are 3 types of trees in it, denoted as 0, 1, 2. Your task is to divide it into K parts such that each part has at least one tree of type 2.
Rules are as follows:
Vertical Cut through the whole grid, you will give the left part to a person, and it will no longer be considered.
Horizontal Cut through the whole grid, give the top part to a person, and it will no longer be considered.
Find the number of ways to do it. Because the number may be too large, return it modulo 1000000007.
Constraint
Not Given.
There is a rectangular
forest with a total of m * n trees planted, with a
total of 3 species of trees, number 1 means pine
tree, 2 means poplar
tree and 3 means willow tree.
Now the forest needs to be divided into x parts
for x people to take care
of. The forest can be divided horizontally or vertically, and each division
needs to divide the whole forest into two parts. If the division is
horizontal, give the top one to one person and continue to divide the
forest below; if the division is vertical, give the left one to one person
and continue to divide the forest on the right. You need to make sure
that each person has at least one poplar tree.
Please calculate how many divisions there are in total. Since the answer
may be a very large number, please return the result of taking the
remainder of 10e9+7.
Input:forest = [[1, 2, 3], [2, 1, 2], [3, 1, 1]], number = 3.
Output: 4
Question 1
Overview
Solution
Question
Overview
Solution