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 7a73813 + 4b5cf23 commit bf1e9f0Copy full SHA for bf1e9f0
3136. Valid Word
@@ -0,0 +1,18 @@
1
+// bitset version
2
+class Solution {
3
+public:
4
+ bool isValid(string& word) {
5
+ const int n=word.size();
6
+ if (n<3) return 0;
7
+ bitset<2> v=0;
8
+ constexpr unsigned vowels=1|(1<<('e'-'a'))|(1<<('o'-'a'))|(1<<('i'-'a'))|(1<<('u'-'a'));
9
+ for(char c: word){
10
+ if (!isalpha(c) && !isdigit(c)) return 0;
11
+ if (isalpha(c)){
12
+ unsigned i=(c>'Z')?c-'a':c-'A';
13
+ v[(vowels>>i)&1]=1;
14
+ }
15
16
+ return v==3;
17
18
+};
0 commit comments