Rust translated, 0ms 100%
rust\nimpl Solution {\n    pub fn num_moves_stones_ii(mut a: Vec<i32>) -> Vec<i32> {\n        a.sort();\n        let mut i = 0;\n        let n = a.len();\n     
```rust\nimpl Solution {\n    pub fn num_moves_stones_ii(mut a: Vec<i32>) -> Vec<i32> {\n        a.sort();\n        let mut i = 0;\n        let n = a.len();\n        let mut lo = n as i32;\n        let hi = std::cmp::max(\n            a[n - 1] - n as i32 + 2 - a[1],\n            a[n - 2] - a[0] - n as i32 + 2,\n        );\n        for j in 0..n {\n            while a[j] - a[i] >= n as i32 {\n                i += 1;\n            }\n            if j - i + 1 == n - 1 && a[j] - a[i] == n as i32 - 2 {\n                lo = std::cmp::min(lo, 2);\n            } else {\n                lo = std::cmp::min(lo, n as i32 - (j - i + 1) as i32);\n            }\n        }\n        vec![lo, hi]\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn test_num_moves_stones_ii() {\n        assert_eq!(Solution::num_moves_stones_ii(vec![7, 4, 9]), vec![1, 2]);\n    }\n\n    #[test]\n    fn test_num_moves_stones_ii_02() {\n        assert_eq!(\n            Solution::num_moves_stones_ii(vec![6, 5, 4, 3, 10]),\n            vec![2, 3]\n        );\n    }\n\n    #[test]\n    fn test_num_moves_stones_ii_03() {\n        assert_eq!(\n            Solution::num_moves_stones_ii(vec![100, 101, 104, 102, 103]),\n            vec![0, 0]\n        );\n    }\n}\n```
[]