Untitled
unknown
plain_text
12 days ago
514 B
2
Indexable
class Solution { public int countVowelStrings(int n) { return solve(0, n); } private int solve(int index, int remLength) { // Base case: If no length is remaining, we have formed a valid string if (remLength == 0) return 1; int ways = 0; // Iterate through all valid vowel indices starting from the current index for (int i = index; i < 5; i++) { ways += solve(i, remLength - 1); } return ways; } }
Editor is loading...
Leave a Comment