You are viewing a single comment's thread. Return to all comments →
Rust best solution If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions
fn caesar_cipher(s: &str, k: i32) -> String { //Time complexity: O(n) //Space complexity (ignoring input): O(n) let mut new_string = String::with_capacity(s.len()); let k = k as u8; for letter in s.chars() { if letter.is_alphabetic() { let sum_a = if letter.is_uppercase() { b'A' } else { b'a' }; new_string.push(((letter as u8 - sum_a + k) % (b'z' - b'a' + 1) + sum_a) as char); } else { new_string.push(letter); } } new_string }
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
Rust best solution
If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions