나는 이렇게 학습한다/Algorithm & SQL
1207. Vowel Count
daco2020
2022. 12. 7. 22:23
Return the number (count) of vowels in the given string.
We will consider a, e, i, o, u as vowels for this Kata (but not y).
The input string will only consist of lower case letters and/or spaces.
Solution:
int getCount(String inputStr){
List<String> arr = [];
for (String s in inputStr.toLowerCase().split('')) {
if (["a","e","i","o","u"].contains(s)) {
arr.add(s);
}
}
return arr.length;
}
import "dart:core";
int getCount(String str) => new RegExp('[aeiou]').allMatches(str).length;
int getCount(String inputStr){
return inputStr.split('').fold(0, (a, b) => a += 'aeiou'.contains(b) ? 1 : 0 );
}