impl Solution { fntry_match(q: &String, p: &String) ->bool { let (m, n, mut i, mut j) = (p.len(), q.len(), 0, 0); while i < n { if j == m && q.chars().nth(i).unwrap().is_uppercase() { returnfalse; } if (j == m || p.chars().nth(j).unwrap().is_uppercase()) && q.chars().nth(i).unwrap().is_lowercase() { i += 1; continue; } let qi = q.chars().nth(i).unwrap(); let pj = p.chars().nth(j).unwrap(); if pj.is_uppercase() && qi.is_uppercase() && pj != qi { returnfalse; } if pj.is_lowercase() && pj != qi { i += 1; continue; } i+= 1; j += 1; } return i == n && j == m; }
pubfncamel_match(queries: Vec<String>, pattern: String) -> Vec<bool> { letmut ans = Vec::new(); for q in &queries { ans.push(Self::try_match(q, &pattern)); } return ans; } }