Practice Maximum Value at a Given Index in a Bounded Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Construct n positive integers whose total is at most maxSum and whose adjacent values differ by at most 1. Return the greatest possible value at the given zero-based index; the array itself need not be returned.
Source: Maximum Value at a Given Index in a Bounded Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 4, index = 2, maxSum = 6
Output
2
# Example 2
Input
n = 6, index = 1, maxSum = 10
Output
3
Constraints
1 <= n <= maxSum <= 10^9
0 <= index < n
Related LeetCode Problems
Practice more problems similar to Maximum Value at a Given Index in a Bounded Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.