FastPrepMaximum Weighted Sum After Left Rotations
Problems/Maximum Weighted Sum After Left Rotations

Maximum Weighted Sum After Left Rotations

Motive logoMotive● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand Motive onsite report for a full-time role describes the maximum weighted left-rotation task.

Our version is about 99% the same as the reported question.

You are given a non-empty integer array nums of length n.

For an array a, define its weighted sum as a[0] * 1 + a[1] * 2 + ... + a[n - 1] * n.

Consider the original array and every array obtained by left-rotating nums. Return the maximum weighted sum among all n rotations.

Function

maximumWeightedLeftRotation(nums: int[]) → long

Examples

Example 1

nums = [3,2,1]return = 13

The rotations have weighted sums 10 for [3,2,1], 13 for [2,1,3], and 13 for [1,3,2]. The maximum is 13.

Example 2

nums = [8,3,1,2]return = 43

The left rotation [3,1,2,8] has weighted sum 3 + 2 + 6 + 32 = 43, which is the maximum.

Example 3

nums = [-5]return = -5

A length-one array has only its original rotation.

Constraints

  • 1 <= nums.length <= 200000
  • -2147483648 <= nums[i] <= 2147483647
  • Every rotation's weighted sum fits in a signed 64-bit integer.

More Motive Onsite Interview questions

  • Group AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
  • Longest Equal-Zero-One SubarrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
  • Valid Parenthesis StringPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Dec 2025
  • Target Triplet SumONSITE INTERVIEW · Seen Dec 2025
  • Validate IP AddressONSITE INTERVIEW · Seen Dec 2025
  • Generate Palindromic PermutationsONSITE INTERVIEW · Seen Dec 2025
  • Minimum Swaps to Group Circular OnesONSITE INTERVIEW · Seen Dec 2025
  • Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Dec 2025
  • Search in Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Retrieve Vectors by Cosine SimilarityHarvey · ONSITE INTERVIEWHarvey interview questions
  • Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Maximize the Even-Odd Index Product GapInfosys · ONSITE INTERVIEWInfosys interview questions
  • Squirrel Nut Collection Shortest PathAmazon · ONSITE INTERVIEW
  • Expected Value of Modified DiceJane Street · ONSITE INTERVIEWJane Street interview questions
  • Linear Layer Forward and Backward PassesMeta · ONSITE INTERVIEWMeta interview questions
  • Product Total With the Cheapest PromotionInstacart · ONSITE INTERVIEWInstacart interview questions
  • Reservoir Sampling with Recorded DrawsStackAdapt · ONSITE INTERVIEWStackAdapt interview questions
  • Koko Eating BananasTekion · ONSITE INTERVIEWTekion interview questions
  • Dense Vector Dot ProductCerebras · ONSITE INTERVIEW
All Motive interview questionsSee Motive hiring insights
Saved
class Solution {
    public long maximumWeightedLeftRotation(int[] nums) {
        // write your code here
    }
}
Checking account…