impl Solution { pubfnshortest_way(source: String, target: String) -> i32 { let (ss, st, mut ans) = (source.len(), target.len(), 1); letmut set = HashSet::new(); for c in source.chars() { set.insert(c); } let (mut i, mut j) = (0, 0); while i < st { if !set.contains(&target.chars().nth(i).unwrap()) { return -1; } while j < ss && source.chars().nth(j).unwrap() != target.chars().nth(i).unwrap() { j += 1; } if j == ss { j = 0; i -= 1; ans += 1; } else { j += 1; } i += 1; }