Practice Get Maximum in Generated 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
Generate nums through index n. Set nums[0] = 0 and, when n is at least 1, nums[1] = 1. For later valid indices, set nums[2*i] = nums[i] and nums[2*i + 1] = nums[i] + nums[i + 1]. Return the maximum value among nums[0] through nums[n].
Source: Get Maximum in Generated Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 7
Output
3
# Example 2
Input
n = 2
Output
1
# Example 3
Input
n = 3
Output
2
Constraints
0 <= n <= 100
Related LeetCode Problems
Practice more problems similar to Get Maximum in Generated Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.