You are viewing a single comment's thread. Return to all comments →
RUST:
fn superReducedString(s: &str) -> String { let mut last_idx = s.len() as i32; let mut result: Vec<&str> = s.split("").collect(); let mut flag = true; while flag { flag = false; for n in 0..last_idx { if n <= last_idx { let first = n as usize; if result[first] == result[(n+1) as usize] { result.remove(first); result.remove(first); last_idx -=2; flag = true; } } } } if !(result.join("").is_empty()) { return result.join("") } "Empty String".to_string() }
Seems like cookies are disabled on this browser, please enable them to open this website
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
RUST: