Skip to content

Commit 2435c82

Browse files
committed
06/12/2020
1 parent b505ef4 commit 2435c82

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

Daily-challenge/Dec/06/README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
1-
# Find the Smallest Divisor Given a Threshold
2-
Given an array of integers nums and an integer threshold, we will choose a positive integer divisor and divide all the array by it and sum the result of the division. Find the smallest divisor such that the result mentioned above is less than or equal to threshold.
1+
# Populating Next Right Pointers in Each Node II
2+
Given a binary tree
33

4-
Each result of division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).
4+
struct Node {
5+
int val;
6+
Node *left;
7+
Node *right;
8+
Node *next;
9+
}
10+
Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.
511

6-
It is guaranteed that there will be an answer.
12+
Initially, all next pointers are set to NULL.
713

814

915

16+
Follow up:
17+
18+
You may only use constant extra space.
19+
Recursive approach is fine, you may assume implicit stack space does not count as extra space for this problem.
20+
21+
1022
Example 1:
1123

12-
Input: nums = [1,2,5,9], threshold = 6
13-
Output: 5
14-
Explanation: We can get a sum to 17 (1+2+5+9) if the divisor is 1.
15-
If the divisor is 4 we can get a sum to 7 (1+1+2+3) and if the divisor is 5 the sum will be 5 (1+1+1+2).
16-
Example 2:
1724

18-
Input: nums = [2,3,5,7,11], threshold = 11
19-
Output: 3
20-
Example 3:
2125

22-
Input: nums = [19], threshold = 5
23-
Output: 4
26+
Input: root = [1,2,3,4,5,null,7]
27+
Output: [1,#,2,3,#,4,5,7,#]
28+
Explanation: Given the above binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level.
2429

2530

2631
Constraints:
2732

28-
1 <= nums.length <= 5 * 10^4
29-
1 <= nums[i] <= 10^6
30-
nums.length <= threshold <= 10^6 <br>
33+
The number of nodes in the given tree is less than 6000.
34+
-100 <= node.val <= 100 <br>
3135

3236
## Idea
3337
yea ill ttyl

0 commit comments

Comments
 (0)