forked from liuyubobobo/Play-Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (29 loc) · 729 Bytes
/
main.cpp
File metadata and controls
39 lines (29 loc) · 729 Bytes
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
37
38
39
/// Source : https://leetcode.com/problems/camelcase-matching/
/// Author : liuyubobobo
/// Time : 2019-04-06
#include <iostream>
#include <vector>
using namespace std;
/// Greedy
/// Time Complexity: O(n * len(|q|))
/// Space Complexity: O(1)
class Solution {
public:
vector<bool> camelMatch(vector<string>& queries, string pattern) {
vector<bool> res;
for(const string& s : queries)
res.push_back(ok(s, pattern));
return res;
}
private:
bool ok(const string& s, const string& p){
int i = 0;
for(char c: s)
if(c == p[i]) i ++;
else if(isupper(c)) return false;
return i == p.size();
}
};
int main() {
return 0;
}