Skip to content

Commit 55888f0

Browse files
authored
Create check-if-a-string-is-an-acronym-of-words.cpp
1 parent 8da7493 commit 55888f0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
// string
5+
class Solution {
6+
public:
7+
bool isAcronym(vector<string>& words, string s) {
8+
if (size(words) != size(s)) {
9+
return false;
10+
}
11+
for (int i = 0; i < size(words); ++i) {
12+
if (words[i][0] != s[i]) {
13+
return false;
14+
}
15+
}
16+
return true;
17+
}
18+
};

0 commit comments

Comments
 (0)