Skip to content

Commit 37e5e50

Browse files
authored
Create 1641-count-sorted-vowel-strings.js
1 parent 578a42c commit 37e5e50

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

1641-count-sorted-vowel-strings.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @param {number} n
3+
* @return {number}
4+
*/
5+
const countVowelStrings = function (n) {
6+
let mem = [1, 1, 1, 1, 1];
7+
for (let i = 1; i < n; ++i) {
8+
const next = [0, 0, 0, 0, 0];
9+
let tmp = 0;
10+
for (let j = 4; j >= 0; --j) {
11+
tmp += mem[j];
12+
next[j] = tmp;
13+
}
14+
mem = next;
15+
}
16+
let sum = 0;
17+
for (let i of mem) {
18+
sum += i;
19+
}
20+
return sum;
21+
};

0 commit comments

Comments
 (0)