-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCamelcase_Matching.cpp
36 lines (36 loc) · 958 Bytes
/
Camelcase_Matching.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Solution {
public:
bool check(string word,string pattern){
int i =0;
int j = 0;
while(i < word.size() && j < pattern.size()){
if(word[i] != pattern[j] && word[i] >= char(66) && word[i] <=char(90)){
return false;
}
else if(word[i] != pattern[j]){
i++;
}
else{
j++;
i++;
}
}
if(j != pattern.size()){
return false;
}
while(i < word.size()){
if(word[i] >= char(65) && word[i] <= char(90)){
return false;
}
i++;
}
return true;
}
vector<bool> camelMatch(vector<string>& queries, string pattern) {
vector<bool>ans(queries.size());
for(int i =0 ; i < queries.size(); i++){
ans[i] = check(queries[i],pattern);
}
return ans;
}
};