Rust Solution using binaryheap
\nuse std::cmp::*;\nuse std::collections::*;\nimpl Solution {\n  pub fn best_rotation(nums: Vec<i32>) -> i32 {\n    let n = nums.len();\n    let mut max = 0;\n 
```\nuse std::cmp::*;\nuse std::collections::*;\nimpl Solution {\n  pub fn best_rotation(nums: Vec<i32>) -> i32 {\n    let n = nums.len();\n    let mut max = 0;\n    let mut result = 0;\n\n    let mut heap = BinaryHeap::new();\n    let mut count = 0;\n    for i in 0..n {\n      let ii = i as i32;\n      let v = nums[i];\n\n      if v <= ii {\n        count += 1;\n      } else {\n        heap.push((Reverse(v-ii), v));\n      }\n    }\n\n    max = count;\n    for i in 1..n {\n      let ii = i as i32;\n      let k = n - i;\n      let v = nums[k];\n\n      count -= 1;\n      heap.push((Reverse(v+ii), v));    \n      while let Some((Reverse(min), v)) = heap.pop() {\n        if min - ii <= 0 {\n          count += 1;\n        } else {\n          heap.push((Reverse(min), v));\n          break\n        }\n      }\n      \n      if max < count {\n        result = k;\n        max = count;\n      } else if max == count {\n        result = std::cmp::min(result, k);\n      }\n    }\n\n    result as i32\n  }\n}\n```
['Rust']