scala solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nobject Solution {\n    def bestRotation(nums: Array[Int]): Int = {\n        val n = nums.length\n        val change = Array.fill(n)(0)\n        for(i <- 0 until n) change((i - nums(i) + 1 + n) % n) -= 1\n        (1 until n).foldLeft(0)((acc, i) =>{\n            change(i) += change(i - 1) + 1\n            if(change(i) > change(acc)) i else acc\n        })\n    }\n}\n```
['Scala']