@@ -0,0 +1,1308 @@
+//https://www.hackerrank.com/challenges/sherlock-and-valid-string%0A//https://www.hackerrank.com/contests/101hack26/challenges/sherlock-and-valid-string%0Aimport java.io.*;%0Aimport java.util.Arrays;%0A%0Apublic class Solution %7B%0A  public static void main(String%5B%5D args) throws IOException %7B%0A    %0A    //Get input%0A    final char%5B%5D S = (new BufferedReader(new InputStreamReader(System.in))).readLine().toCharArray();%0A    %0A    //Print output%0A    System.out.print(isValid(S) ? %22YES%22 : %22NO%22);%0A  %7D%0A  %0A  private static boolean isValid(final char%5B%5D S)%7B%0A    %0A    //If string contains less than two letters%0A    if(S.length %3C 2)%7B%0A      return true;%0A    %7D%0A    %0A    //Create histogram of letters%0A    final int%5B%5D L = new int%5B26%5D;%0A    for(int i = 0, N = S.length; i %3C N; ++L%5BS%5Bi++%5D - 'a'%5D)%7B%7D%0A    %0A    //Sort the histogram%0A    Arrays.sort(L);%0A    %0A    //Ignore unseen letters%0A    int i = 0;%0A    while(i %3C 26 && L%5Bi%5D == 0)%7B%0A      ++i;%0A    %7D%0A    %0A    //If all letter frequencies are equal%0A    if(L%5Bi%5D == L%5B25%5D)%7B%0A      return true;%0A    %7D%0A    %0A    //If there's one letter above the rest by one%0A    if(L%5B25%5D %3E L%5B24%5D)%7B%0A      return L%5Bi%5D == L%5B24%5D && L%5B25%5D - L%5B24%5D == 1;%0A    %7D%0A    %0A    //If there's one letter below the rest by one or that can be removed%0A    return L%5Bi%5D %3C L%5Bi+1%5D && L%5Bi+1%5D == L%5B25%5D && (L%5Bi%5D == 1 %7C%7C L%5Bi+1%5D - L%5Bi%5D == 1);%0A  %7D%0A%7D%0A

Create sherlock-and-valid-string.java