From 627f2cfa1e0ff9d69ade829e1b7887e62476f92e Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Fri, 20 Oct 2023 10:02:10 -0400 Subject: [PATCH] adding word pattern leetcode problem --- leetcode/p290_word_pattern.cpp | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 leetcode/p290_word_pattern.cpp diff --git a/leetcode/p290_word_pattern.cpp b/leetcode/p290_word_pattern.cpp new file mode 100644 index 0000000..3902485 --- /dev/null +++ b/leetcode/p290_word_pattern.cpp @@ -0,0 +1,47 @@ +class Solution { +public: + bool wordPattern(string pattern, string s) { + map map1; + map map2; + vector v1; + // convert s to v1 + int len = s.length(); + string s1; + // this loop converts string s into a vector + for(int i=0;i