diff --git a/to-lower-case/DaleSeo.rs b/to-lower-case/DaleSeo.rs new file mode 100644 index 0000000000..3fc2638784 --- /dev/null +++ b/to-lower-case/DaleSeo.rs @@ -0,0 +1,15 @@ +// TC: O(n) +// SC: O(n) +impl Solution { + pub fn to_lower_case(s: String) -> String { + s.chars() + .map(|c| { + if c.is_ascii_uppercase() { + (c as u8 + (b'a' - b'A')) as char + } else { + c + } + }) + .collect() + } +}