1
var maxVowels = function (s, k) {2
let vowels = ["a", "e", "i", "o", "u"];4
let start = 0; // the left edge of the window5
let count = 0; // count of vowels for current substring6
// expanding the right edge of the window one character at a time7
for (let end = 0; end < s.length; end++) {8
// increment count of vowels for current substring if the current character is present in vowels array9
if (vowels.includes(s[end])) {12
// if substring is longer than K, let's shrink the window by moving left edge13
if (end - start + 1 > k) {14
// reduce the current count by one if the character on the left edge is vowel15
if (vowels.includes(s[start])) {18
//shrinking the left edge of the window21
// checking if current count is larger than current maximum count22
maxCount = Math.max(maxCount, count);23
// if maxCount is equal to K, no need to check further, it is the max possible count24
if (maxCount == k) return maxCount;