diff options
Diffstat (limited to 'check-if-two-string-arrays-are-equivalent')
-rw-r--r-- | check-if-two-string-arrays-are-equivalent/Cargo.toml | 8 | ||||
-rw-r--r-- | check-if-two-string-arrays-are-equivalent/src/main.rs | 13 |
2 files changed, 21 insertions, 0 deletions
diff --git a/check-if-two-string-arrays-are-equivalent/Cargo.toml b/check-if-two-string-arrays-are-equivalent/Cargo.toml new file mode 100644 index 0000000..1eaa37a --- /dev/null +++ b/check-if-two-string-arrays-are-equivalent/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "check-if-two-string-arrays-are-equivalent" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/check-if-two-string-arrays-are-equivalent/src/main.rs b/check-if-two-string-arrays-are-equivalent/src/main.rs new file mode 100644 index 0000000..6143793 --- /dev/null +++ b/check-if-two-string-arrays-are-equivalent/src/main.rs @@ -0,0 +1,13 @@ +fn main() { + println!("Hello, world!"); +} + +struct Solution; + +impl Solution { + pub fn array_strings_are_equal(word1: Vec<String>, word2: Vec<String>) -> bool { + //word1.iter_mut().reduce(|a, b| {a.push_str(b); a}).unwrap() == word2.iter_mut().reduce(|a, b| {a.push_str(b); a}).unwrap() + //word1.concat() == word2.concat() + word1.iter().flat_map(|x| x.chars()).eq(word2.iter().flat_map(|x| x.chars())) + } +} |