Available question text
For each interior element, determine whether it's greater than all previous elements and smaller than all following elements (beauty 2), else whether it is strictly between its immediate neighbors (beauty 1), otherwise 0; sum these values. The key is using prefix maxima and suffix minima (linear-time, O(n) space or O(1) extra) to handle up to n = 1e5 efficiently.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2012. Sum of Beauty in the Array
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source