C++ solution easy [ reduce to longest increasing substring ]
intuition\n\nthis problem can be reduced down to longest increasing substring [ which was not obvious at first atleast for me ]bcz i was trying sliding window m
**intuition**\n\nthis problem can be reduced down to longest increasing substring `[ which was not obvious at first atleast for me ] `bcz i was trying sliding window most of time with char string getting wrong ans on edge cases\n\n\n**implementation**\n\nin the first part of code i changed the string to numbers that way it will be easier for me write less messy code \n\n   i changed \n\n      a -- > 0 \n      e -- > 1 \n      i -- > 2 \n      o -- > 3 \n      u -- > 4 \n\n   so the string like this " aaeiaeiou " -- > becoms " 001201234 "\n\n   so the question converts to finding the longest increasnig substring which includes the all the no [ 0 , 1 , 2 , 3 , 4 ] , and it must be sorted \n\n   to handle count of different no i have used `cnt`\n\n   to maintain the sorted form we use code like **longest increasing substring** \n\n\n\n\n   ```\n\n     int longestBeautifulSubstring(string A ) {\n        \n        \n        if( A.size() < 5 )return 0 ; \n        \n        for( auto &x : A )  // imprtant step to convert the problem to known problem \n        {\n         if( x == \'a\' ) x = \'0\'; \n         if( x == \'e\' ) x = \'1\'; \n         if( x == \'i\' ) x = \'2\'; \n         if( x == \'o\' ) x = \'3\'; \n         if( x == \'u\' ) x = \'4\'; \n        }\n        \n        // after this we only deal with numbers so our code bit clearer now \n\n        int mx = 0 ; \n        \n        vector< int > t( 10 , 0 ); \n        int cnt = 0 ; \n        int i = 0 ; \n        int j ;\n        \n        \n        \n        for( j = 0 ; j < A.size() ; j++ )\n        {\n            if( j > 0 && A[j] >= A[j-1] ) // increasing contraint [ no strict ]\n            {\n                if( t[A[j]-\'0\']++ == 0 )cnt++; \n                \n                if( cnt == 5 )   // we found increasing substring that contain all 5 no\'s \n                {\n                    mx = max( mx , j-i+1 ); \n                }\n            }\n            else \n            {\n                i = j ;  // starting indext should be from this j now  \n                \n                for( int i = 0 ; i < 5 ; i++ )t[i] = 0 ; \n                cnt = 0 ; \n                t[A[j]-\'0\'] = 1 ;\n                if( A[j] == \'0\' )cnt = 1 ;  // if this char is \'a\' then cnt = 1 ; \n            }\n        }\n        \n        return mx ;  // return the longest increasiong substring that all 5 no in it \n        \n    }\n\n\n   ```
['Sliding Window']