@@ -0,0 +1,1146 @@
+import java.io.*;%0Aimport java.util.*;%0Aimport java.text.*;%0Aimport java.math.*;%0Aimport java.util.regex.*;%0A%0A/**%0A*   Solution to https://www.hackerrank.com/challenges/sherlock-and-valid-string/%0A*/%0Apublic class Solution %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        Scanner in = new Scanner(System.in);%0A%0A        String s = in.nextLine();%0A%0A        int%5B%5D freq = new int%5B'z' - 'a' + 1%5D;%0A%0A        char%5B%5D chars = s.toCharArray();%0A%0A        for (char c : chars) %7B%0A            freq%5Bc - 'a'%5D++;%0A        %7D%0A%0A        boolean sameFreq = sameFreq(freq);%0A%0A        for (int i = 0; i %3C freq.length; i++) %7B%0A            if (freq%5Bi%5D != 0) %7B%0A                freq%5Bi%5D--;%0A%0A                if (sameFreq(freq)) %7B%0A                    sameFreq = true;%0A                %7D%0A%0A                freq%5Bi%5D++;%0A            %7D%0A        %7D%0A%0A        System.out.println(sameFreq ? %22YES%22 : %22NO%22);%0A    %7D%0A%0A    private static boolean sameFreq(int%5B%5D arr) %7B%0A        boolean same = true;%0A        int freq = arr%5B0%5D;%0A%0A        for (int i = 0; i %3C arr.length && same; i++) %7B%0A            if (arr%5Bi%5D != 0) %7B%0A                same &= freq == arr%5Bi%5D;%0A            %7D%0A        %7D%0A%0A        return same;%0A    %7D%0A%7D%0A

Create sherlock-and-valid-string.java