Just a runnable solution
\n\nimpl Solution {\n    pub fn count_complete_substrings(word: String, k: i32) -> i32 {\n        let mut vec = vec![];\n        let mut v = vec![];\n        le
\n```\nimpl Solution {\n    pub fn count_complete_substrings(word: String, k: i32) -> i32 {\n        let mut vec = vec![];\n        let mut v = vec![];\n        let s = word.as_bytes();\n        for i in 1..s.len() {\n            if i < s.len() && (s[i] as i32 - s[i - 1] as i32).abs() > 2 {\n                v.push(i);\n            }\n        }\n        let mut st = 0;\n        let e = s.len() - 1;\n        for it in v {\n            if st < it {\n                vec.push(vec![st, it - 1]);\n            }\n            st = it;\n        }\n        if st <= e {\n            // vec will store ranges in which substring can be formed\n            vec.push(vec![st, e]);\n        }\n        let mut ans = 0;\n        for i in 1..=26 {\n            if i * k <= s.len() as i32 {\n                // func will return number of substrings with i different characters each occuring exactly k times\n                ans += Solution::func(i, k, s, &vec);\n            } else {\n                break;\n            }\n        }\n        ans\n    }\n\n    // Standard sliding window approach counting substrings with length x*k with each character occuring exactly k times\n    fn func(x: i32, k: i32, s: &[u8], vec: &Vec<Vec<usize>>) -> i32 {\n        let mut ans = 0;\n        for it in vec {\n            let mut j = it[0];\n            let e = it[1];\n            let mut cntk = 0;\n            let mut mp = std::collections::HashMap::new();\n            let mut i = it[0];\n            while j <= e {\n                mp.insert(s[j], mp.get(&s[j]).unwrap_or(&0) + 1);\n                if mp.get(&s[j]) == Some(&k) {\n                    cntk += 1;\n                }\n                if j - i + 1 > (x * k) as usize {\n                    mp.insert(s[i], mp.get(&s[i]).unwrap() - 1);\n                    if mp.get(&s[i]) == Some(&(k - 1)) {\n                        cntk -= 1;\n                    }\n                    if mp.get(&s[i]) == Some(&0) {\n                        mp.remove(&s[i]);\n                    }\n                    i += 1;\n                }\n                if mp.len() == x as usize && cntk == mp.len() {\n                    ans += 1;\n                }\n                j += 1;\n            }\n        }\n        ans\n    }\n}\n```
['Rust']