From 4b0a6a01b051a4ebfbc17661d14cb23fe4f275fb Mon Sep 17 00:00:00 2001 From: Orangerot Date: Thu, 27 Jun 2024 11:30:16 +0200 Subject: Initial commit --- check-if-two-string-arrays-are-equivalent/Cargo.toml | 8 ++++++++ check-if-two-string-arrays-are-equivalent/src/main.rs | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 check-if-two-string-arrays-are-equivalent/Cargo.toml create mode 100644 check-if-two-string-arrays-are-equivalent/src/main.rs (limited to 'check-if-two-string-arrays-are-equivalent') 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, word2: Vec) -> 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())) + } +} -- cgit v1.2.3