Tap here to switch tabs
Problem
Submissions

Problem: Rotate Function

Rotate Function gives an integer array and scores each circular rotation by summing each position multiplied by the value at that position after rotation. Return the highest score across all rotations.

Statement

Given an integer array nums, define the rotation function F(k) as the sum of i * nums[(i + k) % n] for each index i, where n is the length of nums.

Return the maximum value of F(k) over all possible rotations k.

Constraints:

  • n == nums.length

  • 1 <= n <= 10^5

  • -100 <= nums[i] <= 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Rotate Function

Rotate Function gives an integer array and scores each circular rotation by summing each position multiplied by the value at that position after rotation. Return the highest score across all rotations.

Statement

Given an integer array nums, define the rotation function F(k) as the sum of i * nums[(i + k) % n] for each index i, where n is the length of nums.

Return the maximum value of F(k) over all possible rotations k.

Constraints:

  • n == nums.length

  • 1 <= n <= 10^5

  • -100 <= nums[i] <= 100