Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a17ba99

Browse files
1023. Camelcase Matching
1 parent 5c8ccdc commit a17ba99

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎camelcase-matching.cpp‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Runtime: 4 ms
2+
// Memory Usage: 8.4 MB
3+
class Solution {
4+
public:
5+
6+
bool match(string &q, string &p) {
7+
int j = 0;
8+
for (char c : q) {
9+
if (c != p[j] && isupper(c)) return false;
10+
if (c == p[j]) {
11+
j++;
12+
}
13+
}
14+
return j == p.size();
15+
}
16+
17+
vector<bool> camelMatch(vector<string>& queries, string pattern) {
18+
vector<bool> res;
19+
for (string q : queries) {
20+
res.push_back(match(q, pattern));
21+
}
22+
return res;
23+
}
24+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /