Rust | Greedy, beats 100%
Complexity\n- Time complexity:\nO(n \log n)\n\n- Space complexity:\nO(n), probably\n\n# Code\nrust\nimpl Solution {\n    pub fn minimum_seconds(vec: Vec<i32>) -
# Complexity\n- Time complexity:\n$$O(n \\log n)$$\n\n- Space complexity:\n$$O(n)$$, probably\n\n# Code\n```rust\nimpl Solution {\n    pub fn minimum_seconds(vec: Vec<i32>) -> i32 {\n        let n = vec.len();\n        let mut idx_vec = vec.into_iter()\n            .enumerate()\n            .map(|(i, e)| (e, i))\n            .collect::<Vec<_>>();\n        idx_vec.sort_unstable(); // :3\n\n        let mut ret = usize::MAX;\n\n        let mut ptr = usize::MIN;\n        while ptr < idx_vec.len() {\n            let mut ptr_next = ptr;\n            while ptr_next < idx_vec.len()\n                && idx_vec[ptr_next].0 == idx_vec[ptr].0 {\n                ptr_next += 1;\n            }\n\n            let idx_frnt = idx_vec[ptr].1;\n            let idx_back = idx_vec[ptr_next - 1].1;\n            let mut _ret = (idx_frnt + n - idx_back) / 2;\n\n            for i in (ptr + 1)..ptr_next {\n                let idx = idx_vec[i].1;\n                let idx_prev = idx_vec[i - 1].1;\n\n                _ret = _ret.max((idx - idx_prev) / 2);\n            }\n\n            ret = ret.min(_ret);\n\n            ptr = ptr_next;\n        }\n\n        ret as i32\n    }\n}\n```
['Greedy', 'Sorting', 'Rust']