Search
⌘K

Leetcode 798. Smallest Rotation with Highest Score

Find the smallest rotation k of nums that maximizes the number of positions where the rotated value is <= its index. With n up to 1e5 and values in [0,n-1], the challenge is to compute each element’s contribution across all rotations efficiently (e.g., by converting valid rotation ranges into range updates and scanning with a prefix sum).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.