Data Structures & AlgorithmsVery hardFlipkart/Uber OA · placement

Over all left rotations of [7, 7, 1, 1, 3, 6], what is the maximum value of Σ i·a[i] (0-based)? (Use R(j) = R(j − 1) + sum − n·a[n − j] to move between rotations in O(1).)

  1. A. 54
  2. B. 43
  3. C. 88
  4. D. 87

Correct answer: C. 88

The rotation values are 54, 71, 88, 69, 50, 43; the maximum is 88. The unrotated array gives 54.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic