Count N | Function to count N - length strings consisting of vowels only sorted lexicographically ; Initializing vector to store count of strings . ; Summing up the total number of combinations . ; Return the result ; Driver Code ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findNumberOfStrings ( int N ) { vector < int > counts ( 5 , 1 ) ; for ( int i = 2 ; i <= N ; i ++ ) { for ( int j = 3 ; j >= 0 ; j -- ) counts [ j ] += counts [ j + 1 ] ; } int ans = 0 ; for ( auto c : counts ) ans += c ; return ans ; } int main ( ) { int N = 2 ; cout << findNumberOfStrings ( N ) ; return 0 ; }