Function to count permutations of string such that no two vowels are adjacent
static int countWays ( String str ) { int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { freq [ i ] = 0 ; } int nvowels = 0 , nconsonants = 0 ; int vplaces , cways , vways ;