Brute DFS with Vec<u32> representation for Strings
Approach\n Describe your approach to solving the problem. \nGo through all possible strings with DFS. Track if a string already occured in the DFS and terminate
# Approach\n<!-- Describe your approach to solving the problem. -->\nGo through all possible strings with DFS. Track if a string already occured in the DFS and terminate branch if so. The strings are represented as Vec\'s of u32 for faster execution of operations a and b.\n\n# Code\n```\nuse std::collections::HashSet;\n\ntype SVec = Vec<u32>;\n\nstruct Results{\n    occured: HashSet<SVec>,\n}\n\nimpl Results {\n    fn new() -> Results {\n        Results { occured: HashSet::new() }\n    }\n\n    fn check_in(&mut self, s: &SVec) -> bool {\n        !self.occured.insert(s.to_vec())\n    }\n}\n\nfn apply_a(s: &SVec, a: i32) -> SVec {\n    s.clone().iter().enumerate().map(|(i, x)| if i % 2 == 1 {((*x as i32 + a) % 10) as u32} else {*x}).collect()\n}\n\nfn apply_b(s: &SVec, b: i32) -> SVec {\n    let mut new_s = s.clone();\n    new_s.rotate_right(b as usize);\n    new_s\n}\n\nfn recurs(results: &mut Results, s: SVec, a: i32, b: i32) {\n    if !results.check_in(&s) {\n        recurs(results, apply_a(&s, a), a, b);\n        recurs(results, apply_b(&s, b), a, b);\n    }\n}\n\nfn digits_to_string(ds: &Vec<u32>) -> String {\n    ds.iter().map(|x| char::from_u32(48 + *x).unwrap()).collect()\n}\n\nimpl Solution {\n    pub fn find_lex_smallest_string(s: String, a: i32, b: i32) -> String {\n        let mut res = Results::new();\n        recurs(&mut res, s.chars().map(|c| c as u32 - \'0\' as u32).collect(), a, b);\n        let x = res.occured.iter().map(|x| digits_to_string(x)).min().unwrap();\n        let mut paded = "0".repeat(s.len() - x.len());\n        paded.push_str(&x);\n        paded\n    }\n\n}\n```
['Rust']