Sliding window with multiple conditions java
Sliding window with multiple conditions, if you can optimize thise code, please add the comment.\n\nclass Solution {\n    public int longestBeautifulSubstring(S
Sliding window with multiple conditions, if you can optimize thise code, please add the comment.\n```\nclass Solution {\n    public int longestBeautifulSubstring(String word) {\n        int max = 0;\n        int start = 0;\n        int end = 0;\n        int len = word.length();\n        char[] vowels = {\'a\', \'e\', \'i\', \'o\', \'u\'};\n        int charIndex = 0;\n        while(end < len) {\n            //If previous character is u and current character is not u, we have got the required string from start to previous index.\n            if(charIndex == 4 && word.charAt(end) != vowels[charIndex]) {\n                max = Math.max(max, end - start);\n                charIndex = 0;\n                start = end;\n                continue;\n            }\n\t\t\t//Skip duplicate vowel character\n            if(word.charAt(end) == vowels[charIndex]) {\n                end++;\n                continue;\n            }  \n\t\t\t//Found the next required vowel.\n            if(word.charAt(end) == vowels[charIndex + 1]) {\n                charIndex++;\n                end++;\n                continue;\n            }\n\t\t\t//Not the vowel string that we want. So reset.\n            if(word.charAt(end) != vowels[charIndex + 1]) {\n                charIndex = 0;\n                while(end < len && word.charAt(end) != vowels[charIndex])\n                    end++;\n                start = end;\n            }\n        }\n        if(charIndex == 4) {\n            max = Math.max(max, end - start);\n        }\n        return max;\n    }\n}\n```
[]