[JAVA] [O(n)]
```\nclass Solution {\n    public int longestBeautifulSubstring(String word) {\n      int max = 0;\n      for(int i = 1;i<word.length();i++){\n         int temp
```\nclass Solution {\n    public int longestBeautifulSubstring(String word) {\n      int max = 0;\n      for(int i = 1;i<word.length();i++){\n         int temp = 1;\n         Set<Character> verify = new HashSet<>();\n         verify.add(word.charAt(i-1));\n         while(i < word.length() && word.charAt(i) >= word.charAt(i-1)){\n            temp++;\n            verify.add(word.charAt(i));\n            i++;\n         }\n         max = verify.size() == 5 ? Math.max(max,temp) : max ;\n      }\n\n      return max;\n    }\n}
['Java']