Skip to content

Instantly share code, notes, and snippets.

@svaza
Created January 29, 2022 14:31
Show Gist options
  • Save svaza/8b8fc650fa689dd622993b264a2c1abb to your computer and use it in GitHub Desktop.
Save svaza/8b8fc650fa689dd622993b264a2c1abb to your computer and use it in GitHub Desktop.
1641. Count Sorted Vowel Strings
// https://leetcode.com/problems/count-sorted-vowel-strings/
function countVowelStrings(n: number): number {
return traverse(n, 0, 0);;
};
const vowels: string[] = [ 'a', 'e', 'i', 'o', 'u' ];
function traverse(n: number, runningCombination: number, runningIdx: number): number {
if(runningCombination == n) {
return 1;
}
let combinationSum = 0;
for(let idx: number = runningIdx; idx < vowels.length; idx++) {
runningCombination++;
combinationSum += traverse(n, runningCombination, idx);
runningCombination--;
}
return combinationSum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment