We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c7a319d + d6b79e3 commit d4d2c6bCopy full SHA for d4d2c6b
2018.11.30-leetcode890/Sagittatius.md
@@ -0,0 +1,35 @@
1
+```
2
+class Solution {
3
+public:
4
+ vector<string> findAndReplacePattern(vector<string>& words, string pattern) {
5
+ vector<string> s;
6
+ for(int i=0;i<words.size();i++)
7
+ {
8
+ map<char,char> cmap;
9
+ string st="";
10
+ bool flag=true;
11
+ if(words[i].size()!=pattern.size())
12
+ continue;
13
+ for(int j=0,k=0;k<pattern.size();j++,k++)
14
15
+ if(cmap.find(pattern[k])==cmap.end()&&st.find(words[i][j])==string::npos)
16
17
+ cmap[pattern[k]]=words[i][j];
18
+ st+=words[i][j];
19
+ }
20
+ else if(cmap[pattern[k]]!=words[i][j])
21
22
+ flag=false;
23
+ break;
24
25
26
+ if(flag==true)
27
28
+ s.push_back(words[i]);
29
30
31
+
32
+ return s;
33
34
+};
35
0 commit comments