You are viewing a single comment's thread. Return to all comments →
Rust solution:
fn repeated_string(s: &str, n: i64) -> i64 { let str_length = s.len(); if str_length == 0 { return 0; } let a_count = s.bytes().filter(|&b| b == b'a').count(); let modulo = n as usize % str_length; let remainder_count = s[..modulo].bytes().filter(|&b| b == b'a').count(); let repeats = (n as usize) / str_length; (remainder_count + (a_count * repeats)) as i64 }
Seems like cookies are disabled on this browser, please enable them to open this website
Repeated String
You are viewing a single comment's thread. Return to all comments →
Rust solution: