Round 1
Questions: You have a garden of length n.
It is given that:
Each position i from 1 to n has a plant with an initial length of 0 meters.
Each plant, if watered, will grow by a[i] meters.
You start at index 0, which is outside the garden, and you can make at most m moves where in each move you can either:
- Move to the right (increasing index by 1)
- Move to the left (decreasing index by 1).
After each move, you can water the plant at the current position (you can move outside the garden).
Your goal is to maximize the minimum length of any plant in the garden after making at most m moves.
Print the maximum possible minimum length of any plant in the garden. Since the answer can be large, return it modulo 1e9 + 7.
Examples:
-
n=2, m=3
arr = [1,2]
With 3 moves, the watering sequence can be [L, L, R].
O/P - 2 -
n=1, m=1
arr = [1]
O/P = 1 -
n=2, m=6
arr=[1,1]
O/P= 3
Final array after 6 moves is [3,3]
Candidate's Approach
The candidate attempted to use Binary Search on the answer space but was unable to pass the hidden test cases. No specific approach details were provided.
Interviewer's Feedback
No feedback provided.