Just a runnable solution
Code\n\nimpl Solution {\n    pub fn best_rotation(nums: Vec<i32>) -> i32 {\n        let n = nums.len();\n        let mut diff = vec![1; n];\n        for i in 0.
# Code\n```\nimpl Solution {\n    pub fn best_rotation(nums: Vec<i32>) -> i32 {\n        let n = nums.len();\n        let mut diff = vec![1; n];\n        for i in 0..n {\n            diff[(i + n - nums[i] as usize + 1) % n] -= 1;\n        }\n        let mut ans = 0;\n        let mut prefix = 0;\n        let mut mx = std::i32::MIN;\n        for i in 0..n {\n            prefix += diff[i];\n            if prefix > mx {\n                mx = prefix;\n                ans = i;\n            }\n        }\n        ans as i32\n    }\n}\n```
['Rust']