2019-11-10 LeetCode in Rust LeetCode 1087. Brace Expansion Problem Statement impl Solution { pub fn expand(s: String) -> Vec<String> { let (mut ans, mut prev) : (Vec<String>, Vec<String>) = (vec![], vec![]); let (mut in_brace, mut initialized) = (false, false); for c in s.chars() { if c == '{' { prev = ans.clone(); ans.clear(); in_brace = true; continue; } else if c == '}' { in_brace = false; if !initialized { initialized = true; } continue; } else if c == ',' { continue; } if in_brace { if !initialized { ans.push(c.to_string()); } else { let mut cur = prev.clone(); for i in 0..cur.len() { cur[i].push(c); } for str in cur { ans.push(str); } } } else { if !initialized { ans.push(c.to_string()); initialized = true; } else { for i in 0..ans.len() { ans[i].push(c); } } } } ans.sort(); return ans; }} Newer LeetCode 1079. Letter Tile Possibilities Older LeetCode 1088. Confusing Number II