Rotate Function
Medium · Math & Number Theory · about 20 minutes
Asked at Amazon, Google, Meta, Bloomberg.
nums has length n. Rotate it right by k places and call the result arr_k. Give each rotation a score: multiply every element of arr_k by its position and add the products. Return the highest score among the n rotations (k = 0 … n − 1); it fits in a signed 32-bit integer.