Tap here to switch tabs
Problem
Submissions

Problem: Smallest Rotation with Highest Score

med
30 min
Try to solve the Smallest Rotation with Highest Score problem.

Statement

Given an integer array nums, rotating the array by an integer k (where 0≤0 \leq k << nums.length) shifts each element to the left cyclically by k positions.

For any given rotation k, a score is calculated as the number of indices i where nums[i] ≤\leq i.

Return the rotation index k that yields the maximum possible score. If there are multiple values of k that achieve the maximum score, return the smallest such k.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] << nums.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Smallest Rotation with Highest Score

med
30 min
Try to solve the Smallest Rotation with Highest Score problem.

Statement

Given an integer array nums, rotating the array by an integer k (where 0≤0 \leq k << nums.length) shifts each element to the left cyclically by k positions.

For any given rotation k, a score is calculated as the number of indices i where nums[i] ≤\leq i.

Return the rotation index k that yields the maximum possible score. If there are multiple values of k that achieve the maximum score, return the smallest such k.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] << nums.length