Greatest Common Divisor of Strings LeetCode solution in Rust
1impl Solution {2pub fn gcd_of_strings(str1: String, str2: String) -> String {3if &(str1.clone() + &str2) != &(str2.clone() + &str1) {4return "".to_string();5}6let length = gcd(str1.len(), str2.len());7str1[0..length].to_owned()8}9}10pub fn gcd(n1: usize, n2: usize) -> usize {11if n2 == 0 {12return n1;13}14gcd(n2, n1 % n2)15}