[🦀] Rust O(n)/O(1) solution (55ms)
Complexity\n- Time complexity: O(n)\n- Space complexity: O(1)\n\n# Code\n\nimpl Solution {\n    pub fn count_complete_substrings(s: String, k: i32) -> i32 {\n  
# Complexity\n- Time complexity: O(n)\n- Space complexity: O(1)\n\n# Code\n```\nimpl Solution {\n    pub fn count_complete_substrings(s: String, k: i32) -> i32 {\n        let xs = s.bytes().map(|b| b - b\'a\').collect();\n\n        (1..=26).map(|i| Self::countSliding(&xs, k, i * k as usize)).sum()\n    }\n\n    fn countSliding(xs: &Vec<u8>, k: i32, n: usize) -> i32 {\n        if n > xs.len() { return 0; }\n\n        let (mut cs, mut res, mut q) = (vec![0; 26], 0, 0);\n\n        for i in 0..xs.len() {\n            let j = i - n;\n            cs[xs[i] as usize] += 1;\n            if i >= n { cs[xs[j] as usize] -= 1; }\n            if i > 0  && xs[i].abs_diff(xs[i - 1]) > 2 { q += 1; }\n            if i >= n && xs[j].abs_diff(xs[j + 1]) > 2 { q -= 1; }\n            if i >= n - 1 && q == 0 && cs.iter().all(|&x| x == 0 || x == k) { res += 1; }\n        }\n\n        res\n    }\n}\n```
['Rust']