Skip to content

Commit 8e06ca7

Browse files
authored
Create GatesMa.md
1 parent 256c015 commit 8e06ca7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

2018.11.30-leetcode890/GatesMa.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# C++
2+
```
3+
class Solution {
4+
public:
5+
bool strMatch(string str, string pattern){
6+
int len = str.length();
7+
for(int i=0;i < len;i++){
8+
for(int j=i+1;j < len;j++){
9+
if((str[i] == str[j]) && (pattern[i] != pattern[j])) return false;
10+
if((str[i] != str[j]) && (pattern[i] == pattern[j])) return false;
11+
}
12+
}
13+
return true;
14+
}
15+
vector<string> findAndReplacePattern(vector<string>& words, string pattern) {
16+
vector<string> set;
17+
for(int i=0;i < words.size();i++){
18+
if(strMatch(words[i], pattern)){
19+
set.push_back(words[i]);
20+
}
21+
}
22+
return set;
23+
}
24+
};
25+
```

0 commit comments

Comments
 (0)