bowang0911/leetcode huggingface dataset:
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 `ith` job, you have to finish all the jobs `j` where `0 <= j < i`).

You have to finish **at least** one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the `d` days. The difficulty of a day is the maximum difficulty of a job done on that day.

You are given an integer array `jobDifficulty` and an integer `d`. The difficulty of the `ith` job is `jobDifficulty[i]`.

Return _the minimum difficulty of a job schedule_. If you cannot find a schedule for the jobs return `-1`.

**Example 1:**

**Input:** jobDifficulty = \[6,5,4,3,2,1\], d = 2
**Output:** 7
**Explanation:** First day you can finish the first 5 jobs, total difficulty = 6.
Second day you can finish the last job, total difficulty = 1.
The difficulty of the schedule = 6 + 1 = 7 

**Example 2:**

**Input:** jobDifficulty = \[9,9,9\], d = 4
**Output:** -1
**Explanation:** If you finish a job per day you will still have a free day. you cannot find a schedule for the given jobs.

**Example 3:**

**Input:** jobDifficulty = \[1,1,1\], d = 3
**Output:** 3
**Explanation:** The schedule is one job per day. total difficulty will be 3.

**Constraints:**

*   `1 <= jobDifficulty.length <= 300`
*   `0 <= jobDifficulty[i] <= 1000`
*   `1 <= d <= 10`
The K Weakest Rows in a Matrix

You are given an `m x n` binary matrix `mat` of `1`'s (representing soldiers) and `0`'s (representing civilians). The soldiers are positioned **in front** of the civilians. That is, all the `1`'s will appear to the **left** of all the `0`'s in each row.

A row `i` is **weaker** than a row `j` if one of the following is true:

*   The number of soldiers in row `i` is less than the number of soldiers in row `j`.
*   Both rows have the same number of soldiers and `i < j`.

Return _the indices of the_ `k` _**weakest** rows in the matrix ordered from weakest to strongest_.

**Example 1:**

**Input:** mat = 
\[\[1,1,0,0,0\],
 \[1,1,1,1,0\],
 \[1,0,0,0,0\],
 \[1,1,0,0,0\],
 \[1,1,1,1,1\]\], 
k = 3
**Output:** \[2,0,3\]
**Explanation:** 
The number of soldiers in each row is: 
- Row 0: 2 
- Row 1: 4 
- Row 2: 1 
- Row 3: 2 
- Row 4: 5 
The rows ordered from weakest to strongest are \[2,0,3,1,4\].

**Example 2:**

**Input:** mat = 
\[\[1,0,0,0\],
 \[1,1,1,1\],
 \[1,0,0,0\],
 \[1,0,0,0\]\], 
k = 2
**Output:** \[0,2\]
**Explanation:** 
The number of soldiers in each row is: 
- Row 0: 1 
- Row 1: 4 
- Row 2: 1 
- Row 3: 1 
The rows ordered from weakest to strongest are \[0,2,3,1\].

**Constraints:**

*   `m == mat.length`
*   `n == mat[i].length`
*   `2 <= n, m <= 100`
*   `1 <= k <= m`
*   `matrix[i][j]` is either 0 or 1.
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 least** half of the integers of the array are removed_.

**Example 1:**

**Input:** arr = \[3,3,3,3,5,5,5,2,2,7\]
**Output:** 2
**Explanation:** Choosing {3,7} will make the new array \[5,5,5,2,2\] which has size 5 (i.e equal to half of the size of the old array).
Possible sets of size 2 are {3,5},{3,2},{5,2}.
Choosing set {2,7} is not possible as it will make the new array \[3,3,3,3,5,5,5\] which has a size greater than half of the size of the old array.

**Example 2:**

**Input:** arr = \[7,7,7,7,7,7\]
**Output:** 1
**Explanation:** The only possible set you can choose is {7}. This will make the new array empty.

**Constraints:**

*   `2 <= arr.length <= 105`
*   `arr.length` is even.
*   `1 <= arr[i] <= 105`
Maximum Product of Splitted Binary Tree

Given the `root` of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized.

Return _the maximum product of the sums of the two subtrees_. Since the answer may be too large, return it **modulo** `109 + 7`.

**Note** that you need to maximize the answer before taking the mod and not after taking it.

**Example 1:**

**Input:** root = \[1,2,3,4,5,6\]
**Output:** 110
**Explanation:** Remove the red edge and get 2 binary trees with sum 11 and 10. Their product is 110 (11\*10)

**Example 2:**

**Input:** root = \[1,null,2,3,4,null,null,5,6\]
**Output:** 90
**Explanation:** Remove the red edge and get 2 binary trees with sum 15 and 6.Their product is 90 (15\*6)

**Constraints:**

*   The number of nodes in the tree is in the range `[2, 5 * 104]`.
*   `1 <= Node.val <= 104`
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 addition, you can only jump from index `i` to index `j` if `arr[i] > arr[j]` and `arr[i] > arr[k]` for all indices `k` between `i` and `j` (More formally `min(i, j) < k < max(i, j)`).

You can choose any index of the array and start jumping. Return _the maximum number of indices_ you can visit.

Notice that you can not jump outside of the array at any time.

**Example 1:**

**Input:** arr = \[6,4,14,6,8,13,9,7,10,6,12\], d = 2
**Output:** 4
**Explanation:** You can start at index 10. You can jump 10 --> 8 --> 6 --> 7 as shown.
Note that if you start at index 6 you can only jump to index 7. You cannot jump to index 5 because 13 > 9. You cannot jump to index 4 because index 5 is between index 4 and 6 and 13 > 9.
Similarly You cannot jump from index 3 to index 2 or index 1.

**Example 2:**

**Input:** arr = \[3,3,3,3,3\], d = 3
**Output:** 1
**Explanation:** You can start at any index. You always cannot jump to any index.

**Example 3:**

**Input:** arr = \[7,6,5,4,3,2,1\], d = 1
**Output:** 7
**Explanation:** Start at index 0. You can visit all the indicies. 

**Constraints:**

*   `1 <= arr.length <= 1000`
*   `1 <= arr[i] <= 105`
*   `1 <= d <= arr.length`
Number of Steps to Reduce a Number to Zero

Given an integer `num`, return _the number of steps to reduce it to zero_.

In one step, if the current number is even, you have to divide it by `2`, otherwise, you have to subtract `1` from it.

**Example 1:**

**Input:** num = 14
**Output:** 6
**Explanation:** 
Step 1) 14 is even; divide by 2 and obtain 7. 
Step 2) 7 is odd; subtract 1 and obtain 6.
Step 3) 6 is even; divide by 2 and obtain 3. 
Step 4) 3 is odd; subtract 1 and obtain 2. 
Step 5) 2 is even; divide by 2 and obtain 1. 
Step 6) 1 is odd; subtract 1 and obtain 0.

**Example 2:**

**Input:** num = 8
**Output:** 4
**Explanation:** 
Step 1) 8 is even; divide by 2 and obtain 4. 
Step 2) 4 is even; divide by 2 and obtain 2. 
Step 3) 2 is even; divide by 2 and obtain 1. 
Step 4) 1 is odd; subtract 1 and obtain 0.

**Example 3:**

**Input:** num = 123
**Output:** 12

**Constraints:**

*   `0 <= num <= 106`
Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold

Given an array of integers `arr` and two integers `k` and `threshold`, return _the number of sub-arrays of size_ `k` _and average greater than or equal to_ `threshold`.

**Example 1:**

**Input:** arr = \[2,2,2,2,5,5,5,8\], k = 3, threshold = 4
**Output:** 3
**Explanation:** Sub-arrays \[2,5,5\],\[5,5,5\] and \[5,5,8\] have averages 4, 5 and 6 respectively. All other sub-arrays of size 3 have averages less than 4 (the threshold).

**Example 2:**

**Input:** arr = \[11,13,17,23,29,31,7,5,2,3\], k = 3, threshold = 5
**Output:** 6
**Explanation:** The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.

**Constraints:**

*   `1 <= arr.length <= 105`
*   `1 <= arr[i] <= 104`
*   `1 <= k <= arr.length`
*   `0 <= threshold <= 104`
Angle Between Hands of a Clock

Given two numbers, `hour` and `minutes`, return _the smaller angle (in degrees) formed between the_ `hour` _and the_ `minute` _hand_.

Answers within `10-5` of the actual value will be accepted as correct.

**Example 1:**

**Input:** hour = 12, minutes = 30
**Output:** 165

**Example 2:**

**Input:** hour = 3, minutes = 30
**Output:** 75

**Example 3:**

**Input:** hour = 3, minutes = 15
**Output:** 7.5

**Constraints:**

*   `1 <= hour <= 12`
*   `0 <= minutes <= 59`
Jump Game IV

Given an array of integers `arr`, you are initially positioned at the first index of the array.

In one step you can jump from index `i` to index:

*   `i + 1` where: `i + 1 < arr.length`.
*   `i - 1` where: `i - 1 >= 0`.
*   `j` where: `arr[i] == arr[j]` and `i != j`.

Return _the minimum number of steps_ to reach the **last index** of the array.

Notice that you can not jump outside of the array at any time.

**Example 1:**

**Input:** arr = \[100,-23,-23,404,100,23,23,23,3,404\]
**Output:** 3
**Explanation:** You need three jumps from index 0 --> 4 --> 3 --> 9. Note that index 9 is the last index of the array.

**Example 2:**

**Input:** arr = \[7\]
**Output:** 0
**Explanation:** Start index is the last index. You do not need to jump.

**Example 3:**

**Input:** arr = \[7,6,9,6,9,6,9,7\]
**Output:** 1
**Explanation:** You can jump directly from index 0 to index 7 which is last index of the array.

**Constraints:**

*   `1 <= arr.length <= 5 * 104`
*   `-108 <= arr[i] <= 108`
Check If N and Its Double Exist

Given an array `arr` of integers, check if there exist two indices `i` and `j` such that :

*   `i != j`
*   `0 <= i, j < arr.length`
*   `arr[i] == 2 * arr[j]`

**Example 1:**

**Input:** arr = \[10,2,5,3\]
**Output:** true
**Explanation:** For i = 0 and j = 2, arr\[i\] == 10 == 2 \* 5 == 2 \* arr\[j\]

**Example 2:**

**Input:** arr = \[3,1,7,11\]
**Output:** false
**Explanation:** There is no i and j that satisfy the conditions.

**Constraints:**

*   `2 <= arr.length <= 500`
*   `-103 <= arr[i] <= 103`
Minimum Number of Steps to Make Two Strings Anagram

You are given two strings of the same length `s` and `t`. In one step you can choose **any character** of `t` and replace it with **another character**.

Return _the minimum number of steps_ to make `t` an anagram of `s`.

An **Anagram** of a string is a string that contains the same characters with a different (or the same) ordering.

**Example 1:**

**Input:** s =  "bab ", t =  "aba "
**Output:** 1
**Explanation:** Replace the first 'a' in t with b, t =  "bba " which is anagram of s.

**Example 2:**

**Input:** s =  "leetcode ", t =  "practice "
**Output:** 5
**Explanation:** Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.

**Example 3:**

**Input:** s =  "anagram ", t =  "mangaar "
**Output:** 0
**Explanation:**  "anagram " and  "mangaar " are anagrams. 

**Constraints:**

*   `1 <= s.length <= 5 * 104`
*   `s.length == t.length`
*   `s` and `t` consist of lowercase English letters only.
Tweet Counts Per Frequency

A social media company is trying to monitor activity on their site by analyzing the number of tweets that occur in select periods of time. These periods can be partitioned into smaller **time chunks** based on a certain frequency (every **minute**, **hour**, or **day**).

For example, the period `[10, 10000]` (in **seconds**) would be partitioned into the following **time chunks** with these frequencies:

*   Every **minute** (60-second chunks): `[10,69]`, `[70,129]`, `[130,189]`, `...`, `[9970,10000]`
*   Every **hour** (3600-second chunks): `[10,3609]`, `[3610,7209]`, `[7210,10000]`
*   Every **day** (86400-second chunks): `[10,10000]`

Notice that the last chunk may be shorter than the specified frequency's chunk size and will always end with the end time of the period (`10000` in the above example).

Design and implement an API to help the company with their analysis.

Implement the `TweetCounts` class:

*   `TweetCounts()` Initializes the `TweetCounts` object.
*   `void recordTweet(String tweetName, int time)` Stores the `tweetName` at the recorded `time` (in **seconds**).
*   `List getTweetCountsPerFrequency(String freq, String tweetName, int startTime, int endTime)` Returns a list of integers representing the number of tweets with `tweetName` in each **time chunk** for the given period of time `[startTime, endTime]` (in **seconds**) and frequency `freq`.
    *   `freq` is one of `"minute "`, `"hour "`, or `"day "` representing a frequency of every **minute**, **hour**, or **day** respectively.

**Example:**

**Input**
\[ "TweetCounts ", "recordTweet ", "recordTweet ", "recordTweet ", "getTweetCountsPerFrequency ", "getTweetCountsPerFrequency ", "recordTweet ", "getTweetCountsPerFrequency "\]
\[\[\],\[ "tweet3 ",0\],\[ "tweet3 ",60\],\[ "tweet3 ",10\],\[ "minute ", "tweet3 ",0,59\],\[ "minute ", "tweet3 ",0,60\],\[ "tweet3 ",120\],\[ "hour ", "tweet3 ",0,210\]\]

**Output**
\[null,null,null,null,\[2\],\[2,1\],null,\[4\]\]

**Explanation**
TweetCounts tweetCounts = new TweetCounts();
tweetCounts.recordTweet( "tweet3 ", 0);                              // New tweet  "tweet3 " at time 0
tweetCounts.recordTweet( "tweet3 ", 60);                             // New tweet  "tweet3 " at time 60
tweetCounts.recordTweet( "tweet3 ", 10);                             // New tweet  "tweet3 " at time 10
tweetCounts.getTweetCountsPerFrequency( "minute ",  "tweet3 ", 0, 59); // return \[2\]; chunk \[0,59\] had 2 tweets
tweetCounts.getTweetCountsPerFrequency( "minute ",  "tweet3 ", 0, 60); // return \[2,1\]; chunk \[0,59\] had 2 tweets, chunk \[60,60\] had 1 tweet
tweetCounts.recordTweet( "tweet3 ", 120);                            // New tweet  "tweet3 " at time 120
tweetCounts.getTweetCountsPerFrequency( "hour ",  "tweet3 ", 0, 210);  // return \[4\]; chunk \[0,210\] had 4 tweets

**Constraints:**

*   `0 <= time, startTime, endTime <= 109`
*   `0 <= endTime - startTime <= 104`
*   There will be at most `104` calls **in total** to `recordTweet` and `getTweetCountsPerFrequency`.
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.

Students can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the student sitting directly in front or behind him. Return the **maximum** number of students that can take the exam together without any cheating being possible..

Students must be placed in seats in good condition.

**Example 1:**

**Input:** seats = \[\[ "# ", ". ", "# ", "# ", ". ", "# "\],
                \[ ". ", "# ", "# ", "# ", "# ", ". "\],
                \[ "# ", ". ", "# ", "# ", ". ", "# "\]\]
**Output:** 4
**Explanation:** Teacher can place 4 students in available seats so they don't cheat on the exam. 

**Example 2:**

**Input:** seats = \[\[ ". ", "# "\],
                \[ "# ", "# "\],
                \[ "# ", ". "\],
                \[ "# ", "# "\],
                \[ ". ", "# "\]\]
**Output:** 3
**Explanation:** Place all students in available seats. 

**Example 3:**

**Input:** seats = \[\[ "# ", ". ", "**.** ", ". ", "# "\],
                \[ "**.** ", "# ", "**.** ", "# ", "**.** "\],
                \[ "**.** ", ". ", "# ", ". ", "**.** "\],
                \[ "**.** ", "# ", "**.** ", "# ", "**.** "\],
                \[ "# ", ". ", "**.** ", ". ", "# "\]\]
**Output:** 10
**Explanation:** Place students in available seats in column 1, 3 and 5.

**Constraints:**

*   `seats` contains only characters `'.' and``'#'.`
*   `m == seats.length`
*   `n == seats[i].length`
*   `1 <= m <= 8`
*   `1 <= n <= 8`
Count Negative Numbers in a Sorted Matrix

Given a `m x n` matrix `grid` which is sorted in non-increasing order both row-wise and column-wise, return _the number of **negative** numbers in_ `grid`.

**Example 1:**

**Input:** grid = \[\[4,3,2,-1\],\[3,2,1,-1\],\[1,1,-1,-2\],\[-1,-1,-2,-3\]\]
**Output:** 8
**Explanation:** There are 8 negatives number in the matrix.

**Example 2:**

**Input:** grid = \[\[3,2\],\[1,0\]\]
**Output:** 0

**Constraints:**

*   `m == grid.length`
*   `n == grid[i].length`
*   `1 <= m, n <= 100`
*   `-100 <= grid[i][j] <= 100`

**Follow up:** Could you find an `O(n + m)` solution?
Product of the Last K Numbers

Design an algorithm that accepts a stream of integers and retrieves the product of the last `k` integers of the stream.

Implement the `ProductOfNumbers` class:

*   `ProductOfNumbers()` Initializes the object with an empty stream.
*   `void add(int num)` Appends the integer `num` to the stream.
*   `int getProduct(int k)` Returns the product of the last `k` numbers in the current list. You can assume that always the current list has at least `k` numbers.

The test cases are generated so that, at any time, the product of any contiguous sequence of numbers will fit into a single 32-bit integer without overflowing.

**Example:**

**Input**
\[ "ProductOfNumbers ", "add ", "add ", "add ", "add ", "add ", "getProduct ", "getProduct ", "getProduct ", "add ", "getProduct "\]
\[\[\],\[3\],\[0\],\[2\],\[5\],\[4\],\[2\],\[3\],\[4\],\[8\],\[2\]\]

**Output**
\[null,null,null,null,null,null,20,40,0,null,32\]

**Explanation**
ProductOfNumbers productOfNumbers = new ProductOfNumbers();
productOfNumbers.add(3);        // \[3\]
productOfNumbers.add(0);        // \[3,0\]
productOfNumbers.add(2);        // \[3,0,2\]
productOfNumbers.add(5);        // \[3,0,2,5\]
productOfNumbers.add(4);        // \[3,0,2,5,4\]
productOfNumbers.getProduct(2); // return 20. The product of the last 2 numbers is 5 \* 4 = 20
productOfNumbers.getProduct(3); // return 40. The product of the last 3 numbers is 2 \* 5 \* 4 = 40
productOfNumbers.getProduct(4); // return 0. The product of the last 4 numbers is 0 \* 2 \* 5 \* 4 = 0
productOfNumbers.add(8);        // \[3,0,2,5,4,8\]
productOfNumbers.getProduct(2); // return 32. The product of the last 2 numbers is 4 \* 8 = 32 

**Constraints:**

*   `0 <= num <= 100`
*   `1 <= k <= 4 * 104`
*   At most `4 * 104` calls will be made to `add` and `getProduct`.
*   The product of the stream at any point in time will fit in a **32-bit** integer.
Maximum Number of Events That Can Be Attended

You are 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` where `startTimei <= d <= endTimei`. You can only attend one event at any time `d`.

Return _the maximum number of events you can attend_.

**Example 1:**

**Input:** events = \[\[1,2\],\[2,3\],\[3,4\]\]
**Output:** 3
**Explanation:** You can attend all the three events.
One way to attend them all is as shown.
Attend the first event on day 1.
Attend the second event on day 2.
Attend the third event on day 3.

**Example 2:**

**Input:** events= \[\[1,2\],\[2,3\],\[3,4\],\[1,2\]\]
**Output:** 4

**Constraints:**

*   `1 <= events.length <= 105`
*   `events[i].length == 2`
*   `1 <= startDayi <= endDayi <= 105`
Construct Target Array With Multiple Sums

You are given an array `target` of n integers. From a starting array `arr` consisting of `n` 1's, you may perform the following procedure :

*   let `x` be the sum of all elements currently in your array.
*   choose index `i`, such that `0 <= i < n` and set the value of `arr` at index `i` to `x`.
*   You may repeat this procedure as many times as needed.

Return `true` _if it is possible to construct the_ `target` _array from_ `arr`_, otherwise, return_ `false`.

**Example 1:**

**Input:** target = \[9,3,5\]
**Output:** true
**Explanation:** Start with arr = \[1, 1, 1\] 
\[1, 1, 1\], sum = 3 choose index 1
\[1, 3, 1\], sum = 5 choose index 2
\[1, 3, 5\], sum = 9 choose index 0
\[9, 3, 5\] Done

**Example 2:**

**Input:** target = \[1,1,1,2\]
**Output:** false
**Explanation:** Impossible to create target array from \[1,1,1,1\].

**Example 3:**

**Input:** target = \[8,5\]
**Output:** true

**Constraints:**

*   `n == target.length`
*   `1 <= n <= 5 * 104`
*   `1 <= target[i] <= 109`
Sort Integers by The Number of 1 Bits

You are given an integer array `arr`. Sort the integers in the array in ascending order by the number of `1`'s in their binary representation and in case of two or more integers have the same number of `1`'s you have to sort them in ascending order.

Return _the array after sorting it_.

**Example 1:**

**Input:** arr = \[0,1,2,3,4,5,6,7,8\]
**Output:** \[0,1,2,4,8,3,5,6,7\]
**Explantion:** \[0\] is the only integer with 0 bits.
\[1,2,4,8\] all have 1 bit.
\[3,5,6\] have 2 bits.
\[7\] has 3 bits.
The sorted array by bits is \[0,1,2,4,8,3,5,6,7\]

**Example 2:**

**Input:** arr = \[1024,512,256,128,64,32,16,8,4,2,1\]
**Output:** \[1,2,4,8,16,32,64,128,256,512,1024\]
**Explantion:** All integers have 1 bit in the binary representation, you should just sort them in ascending order.

**Constraints:**

*   `1 <= arr.length <= 500`
*   `0 <= arr[i] <= 104`
Number of Substrings Containing All Three Characters

Given a string `s` consisting only of characters _a_, _b_ and _c_.

Return the number of substrings containing **at least** one occurrence of all these characters _a_, _b_ and _c_.

**Example 1:**

**Input:** s =  "abcabc "
**Output:** 10
**Explanation:** The substrings containing at least one occurrence of the characters _a_, _b_ and _c are  "_abc _",  "_abca _",  "_abcab _",  "_abcabc _",  "_bca _",  "_bcab _",  "_bcabc _",  "_cab _",  "_cabc _"_ and  _"_abc _"_ (**again**)_._ 

**Example 2:**

**Input:** s =  "aaacb "
**Output:** 3
**Explanation:** The substrings containing at least one occurrence of the characters _a_, _b_ and _c are  "_aaacb _",  "_aacb _"_ and  _"_acb _"._ 

**Example 3:**

**Input:** s =  "abc "
**Output:** 1

**Constraints:**

*   `3 <= s.length <= 5 x 10^4`
*   `s` only consists of _a_, _b_ or _c_ characters.
Count All Valid Pickup and Delivery Options

Given `n` orders, each order consist in pickup and delivery services.

Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i).

Since the answer may be too large, return it modulo 10^9 + 7.

**Example 1:**

**Input:** n = 1
**Output:** 1
**Explanation:** Unique order (P1, D1), Delivery 1 always is after of Pickup 1.

**Example 2:**

**Input:** n = 2
**Output:** 6
**Explanation:** All possible orders: 
(P1,P2,D1,D2), (P1,P2,D2,D1), (P1,D1,P2,D2), (P2,P1,D1,D2), (P2,P1,D2,D1) and (P2,D2,P1,D1).
This is an invalid order (P1,D2,P2,D1) because Pickup 2 is after of Delivery 2.

**Example 3:**

**Input:** n = 3
**Output:** 90

**Constraints:**

*   `1 <= n <= 500`

Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p\[0\] = start, p\[i\] and p\[i+1\] differ by only one bit for all 0 <= i < 2^n - 1.
Number of Days Between Two Dates

Write a program to count the number of days between two dates.

The two dates are given as strings, their format is `YYYY-MM-DD` as shown in the examples.

**Example 1:**

**Input:** date1 = "2019-06-29", date2 = "2019-06-30"
**Output:** 1

**Example 2:**

**Input:** date1 = "2020-01-15", date2 = "2019-12-31"
**Output:** 15

**Constraints:**

*   The given dates are valid dates between the years `1971` and `2100`.
Validate Binary Tree Nodes

You have `n` binary tree nodes numbered from `0` to `n - 1` where node `i` has two children `leftChild[i]` and `rightChild[i]`, return `true` if and only if **all** the given nodes form **exactly one** valid binary tree.

If node `i` has no left child then `leftChild[i]` will equal `-1`, similarly for the right child.

Note that the nodes have no values and that we only use the node numbers in this problem.

**Example 1:**

**Input:** n = 4, leftChild = \[1,-1,3,-1\], rightChild = \[2,-1,-1,-1\]
**Output:** true

**Example 2:**

**Input:** n = 4, leftChild = \[1,-1,3,-1\], rightChild = \[2,3,-1,-1\]
**Output:** false

**Example 3:**

**Input:** n = 2, leftChild = \[1,0\], rightChild = \[-1,-1\]
**Output:** false

**Constraints:**

*   `n == leftChild.length == rightChild.length`
*   `1 <= n <= 104`
*   `-1 <= leftChild[i], rightChild[i] <= n - 1`