You are viewing a single comment's thread. Return to all comments →
fn appendAndDelete(s: &str, t: &str, k: i32) -> String { let s_len = s.len() as i32; let t_len = t.len() as i32; let common_len = s.chars().zip(t.chars()).take_while(|a| a.0 == a.1).count() as i32; let min_operations = (s_len - common_len) + (t_len - common_len); if min_operations > k { return "No".into(); } else if (k - min_operations) % 2 == 0 { return "Yes".into(); } else if k >= s_len + t_len { return "Yes".into(); } else { return "No".into(); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Append and Delete
You are viewing a single comment's thread. Return to all comments →