FastPrepIndex of the Maximum After Left Rotations
Problems/Index of the Maximum After Left Rotations

Index of the Maximum After Left Rotations

Chubb logoChubb● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report asks for the index of the maximum element after each rotation query. We chose the rest. Rotation goes left, and the queries are independent of each other. Rotation amounts wrap around with modulo. Indexes start at 0, and ties go to the smallest index. We also chose the function types, the examples, and the limits.

You are given a nonempty integer array arr and an array of nonnegative rotation queries rotate.

Each query is independent. For every rotate[q], start from the original array, rotate it left by that many positions, and return the zero-based index of a maximum element. If the maximum occurs more than once after rotation, return its smallest index. Return one index per query.

Function

maximumIndicesAfterRotations(arr: int[], rotate: int[]) → int[]

Examples

Example 1

arr = [1,5,3]rotate = [0,1,4]return = [1,0,0]

The maximum starts at index 1. One left rotation moves it to index 0; four rotations have the same effect as one.

Example 2

arr = [5,1,5,2]rotate = [0,1,2,3]return = [0,1,0,1]

For each independent rotation, the smaller rotated index among the two maximum values is returned.

Constraints

  • 1 <= arr.length, rotate.length <= 200000.
  • -1000000000 <= arr[i] <= 1000000000.
  • 0 <= rotate[q] <= 1000000000.

More Chubb Online Assessment questions

  • Count Pairs with K Divisible Values in the IntervalOA · Seen Oct 2026
  • Maximize Revenue from Decreasing InventoryOA · Seen Oct 2026
  • Minimize the Maximum Array ElementOA · Seen Oct 2026
  • Minimum Distinct Prefix CostOA · Seen Oct 2026
  • Flat JSON Value DifferencesOA · Seen Sep 2026
  • Maximum Student-Teacher DistanceOA · Seen Sep 2026
  • Minimum Cost to Reach a Target WeightOA · Seen Sep 2026
  • Minimum Last-Element RelocationsOA · Seen Sep 2026
  • Most Visited Sprint MarkerOA · Seen Sep 2026
  • How Many Sentences?OA · Seen Sep 2026

Similar questions at other companies

  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • Rolling MetricsAkuna Capital · OAAkuna Capital interview questions
  • Forward Block Placement QueriesCapital One · OACapital One interview questions
  • Souvenir Shop PurchasesAmazon · OA
  • The OraclesRubrik · OARubrik interview questions
  • Online Meeting Scheduler with Fixed RoomsUber · ONSITE INTERVIEWUber interview questions
  • Detect a Silent SensorConfluent · ONSITE INTERVIEWConfluent interview questions
  • Sorted Insertion SnapshotsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Finish Ordered CPU Tasks with the Fewest CPUsGoogle · PHONE SCREENGoogle interview questions
  • Minimum Non-Adjacent Selection CapabilityMicrosoft · OAMicrosoft interview questions
All Chubb interview questionsSee Chubb hiring insights
Saved
class Solution {
    public int[] maximumIndicesAfterRotations(int[] arr, int[] rotate) {
        // Write your solution here.
    }

}
Checking account…