diff --git a/3042. Count Prefix and Suffix Pairs I b/3042. Count Prefix and Suffix Pairs I new file mode 100644 index 0000000..694fbf5 --- /dev/null +++ b/3042. Count Prefix and Suffix Pairs I @@ -0,0 +1,29 @@ +class Solution { +public: + bool isPrefix(string word1, string word2){ + if(word1.size() > word2.size()) return false; + for(int i=0; i word2.size()) return false; + int i=word1.size()-1, j=word2.size()-1; + while(i>=0){ + if(word1[i] != word2[j]) return false; + i--, j--; + } + return true; + } + int countPrefixSuffixPairs(vector& words) { + int count = 0; + for(int i=0; i