If substring till now have all vowels atleast once increment start index until there are all vowels present between ( start , i ) and add n - i each time
while ( mp . ContainsKey ( ' a ' ) && mp . ContainsKey ( ' e ' ) && mp . ContainsKey ( ' i ' ) && mp . ContainsKey ( ' o ' ) && mp . ContainsKey ( ' u ' ) && mp [ ' a ' ] > 0 && mp [ ' e ' ] > 0 && mp [ ' i ' ] > 0 && mp [ ' o ' ] > 0 && mp [ ' u ' ] > 0 ) { count += n - i ; if ( mp . ContainsKey ( s [ start ] ) ) mp [ s [ start ] ] = mp [ s [ start ] ] - 1 ; start ++ ; } } return count ; }