Practice Sum of Beauty in the 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
For each interior index i, score 2 when nums[i] exceeds every earlier value and is below every later value. Otherwise score 1 when nums[i - 1] < nums[i] < nums[i + 1], or 0 if that also fails. Return the sum over indices 1 through nums.length - 2.
Source: Sum of Beauty in the Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,2,3]
Output
2
# Example 2
Input
nums = [2,4,6,4]
Output
1
# Example 3
Input
nums = [3,2,1]
Output
0
Constraints
3 <= nums.length <= 10^5
1 <= nums[i] <= 10^5
Related LeetCode Problems
Practice more problems similar to Sum of Beauty in the Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.