From 21be9f2c0fe57de16a0128db71a01c921b04ad50 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Wed, 17 Jan 2024 10:48:46 +0800 Subject: [PATCH] 20240117 Finished --- src/problem/mod.rs | 3 +- ...744_find_maximum_number_of_string_pairs.rs | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/problem/p2744_find_maximum_number_of_string_pairs.rs diff --git a/src/problem/mod.rs b/src/problem/mod.rs index f2db715..d2ccbf9 100644 --- a/src/problem/mod.rs +++ b/src/problem/mod.rs @@ -18,4 +18,5 @@ mod p2085_count_common_words_with_one_occurrence; mod p2182_construct_string_with_repeat_limit; mod p83_remove_duplicates_from_sorted_list; mod p82_remove_duplicates_from_sorted_list_ii; -mod p2719_count_of_integers; \ No newline at end of file +mod p2719_count_of_integers; +mod p2744_find_maximum_number_of_string_pairs; \ No newline at end of file diff --git a/src/problem/p2744_find_maximum_number_of_string_pairs.rs b/src/problem/p2744_find_maximum_number_of_string_pairs.rs new file mode 100644 index 0000000..7db81c7 --- /dev/null +++ b/src/problem/p2744_find_maximum_number_of_string_pairs.rs @@ -0,0 +1,36 @@ +/** + * [2744] Find Maximum Number of String Pairs + */ +pub struct Solution {} + + +// submission codes start here + +impl Solution { + pub fn maximum_number_of_string_pairs(words: Vec) -> i32 { + let mut result = 0; + + for i in 0..words.len() { + let word: String = words[i].chars().rev().collect(); + + for j in (i + 1)..words.len() { + if word == words[j] { + result += 1; + } + } + } + + result + } +} + +// submission codes end + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_2744() { + } +}