C++✅✅ | Faster🚀 than 90%🔥| A TRICK TO HANDLE ORDERING👌| Sliding Window🆗 |
\n\n# Code\n\n\nclass Solution {\npublic:\n\n    int longestBeautifulSubstring(string w) {\n        \n      int n = w.size();\n      vector<pair<char,int>>vp;\n
\n\n# Code\n```\n\nclass Solution {\npublic:\n\n    int longestBeautifulSubstring(string w) {\n        \n      int n = w.size();\n      vector<pair<char,int>>vp;\n      char curr = w[0];\n      int cnt = 0;\n      for(int i = 0;i<n;)\n      {\n        while(w[i]==curr && i < n)\n        {\n          i++; cnt++;\n        }\n        vp.push_back({curr,cnt});\n        curr = w[i];\n        cnt = 0;\n      }\n      int maxi = 0;\n      n = vp.size();\n\n      if(n < 5) return 0;\n\n      string t;\n      string s = "aeiou";\n      cnt = 0;\n      int i = 0, j = 0;\n\n      for(;j<5;++j)\n      {\n        t.push_back(vp[j].first);\n        cnt += vp[j].second;\n      }\n\n      if(t==s) maxi = max(maxi,cnt);\n    \n      for(;j<n;++j)\n      {\n        t.erase(t.begin());\n        t.push_back(vp[j].first);\n        cnt-= vp[i].second;\n        i++;\n        cnt+=vp[j].second;\n        if(t==s) maxi = max(maxi,cnt); \n      }\n      \n      return maxi;\n    }\n};\n\n```
['C++']