Skip to content

Commit 4a2985f

Browse files
authored
Create 2947-count-beautiful-substrings-i.js
1 parent 9c1303d commit 4a2985f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

2947-count-beautiful-substrings-i.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @param {string} s
3+
* @param {number} k
4+
* @return {number}
5+
*/
6+
var beautifulSubstrings = function(s, k) {
7+
let counter=0;
8+
for(let i=0;i<s.length;i++){
9+
let vow=0;
10+
let con=0;
11+
for(let j=i;j<s.length;j++){
12+
let c=s.charAt(j);
13+
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
14+
vow++;
15+
}
16+
let df=j-i;
17+
df++;
18+
con=df;
19+
con=con-vow;
20+
21+
if(vow==con &&(vow*con)%k==0){
22+
counter++;
23+
}
24+
}
25+
}
26+
return counter;
27+
};

0 commit comments

Comments
 (0)