Java || String Manipulation(Sliding window variation) ✅
\nclass Solution {\n    public boolean isDistinct(char a, char b){\n        return a!=b;\n    }\n    public int longestBeautifulSubstring(String word) {\n      
```\nclass Solution {\n    public boolean isDistinct(char a, char b){\n        return a!=b;\n    }\n    public int longestBeautifulSubstring(String word) {\n        int maxLen = 0, n = word.length(), count = 1, wordLength = 1;\n        for(int i = 1;i<n;i++){\n            if(word.charAt(i-1) <= word.charAt(i)){\n                if(isDistinct(word.charAt(i-1), word.charAt(i))){\n                    count++;\n                }\n                wordLength++;\n                if(count == 5){\n                    maxLen = Math.max(maxLen, wordLength);\n                }\n            }\n            else{\n                count = 1;\n                wordLength = 1;\n            }\n        }\n        return maxLen;\n    }\n}\n```
['String', 'Sliding Window', 'Java']