@@ -0,0 +1,1831 @@
+import java.io.*;%0Aimport java.math.*;%0Aimport java.security.*;%0Aimport java.text.*;%0Aimport java.util.*;%0Aimport java.util.concurrent.*;%0Aimport java.util.regex.*;%0A%0Apublic class Solution %7B%0A%0A    // Complete the happyLadybugs function below.%0A    static String happyLadybugs(String b) %7B%0A        char%5B%5D arr = b.toCharArray();%0A        HashMap%3CCharacter,Integer%3E hm = new HashMap();%0A        for(int i=0;i%3Carr.length;i++)%7B%0A            if(hm.containsKey(arr%5Bi%5D)) %7B%0A                hm.put(arr%5Bi%5D,hm.get(arr%5Bi%5D)+1);%0A            %7D%0A            else hm.put(arr%5Bi%5D,1);%0A        %7D%0A        Set%3CCharacter%3E s = hm.keySet();%0A        boolean present =false;%0A        for(char c : s)%7B%0A            if(c!='_')%7B%0A                if(hm.get(c)==1) return %22NO%22;%0A            %7D%0A            else present = true;%0A        %7D%0A        if(!present)%7B%0A            if(arr.length==1) return %22NO%22;%0A            if(arr%5B0%5D!=arr%5B1%5D %7C%7C arr%5Barr.length-1%5D!=arr%5Barr.length-2%5D) return %22NO%22;%0A            for(int i=2;i%3Carr.length-2;i++)%7B%0A                if(arr%5Bi+1%5D!=arr%5Bi%5D && arr%5Bi-1%5D!=arr%5Bi%5D) return %22NO%22;%0A            %7D%0A        %7D%0A        return %22YES%22;%0A    %7D%0A%0A    private static final Scanner scanner = new Scanner(System.in);%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv(%22OUTPUT_PATH%22)));%0A%0A        int g = scanner.nextInt();%0A        scanner.skip(%22(%5Cr%5Cn%7C%5B%5Cn%5Cr%5Cu2028%5Cu2029%5Cu0085%5D)?%22);%0A%0A        for (int gItr = 0; gItr %3C g; gItr++) %7B%0A            int n = scanner.nextInt();%0A            scanner.skip(%22(%5Cr%5Cn%7C%5B%5Cn%5Cr%5Cu2028%5Cu2029%5Cu0085%5D)?%22);%0A%0A            String b = scanner.nextLine();%0A%0A            String result = happyLadybugs(b);%0A%0A            bufferedWriter.write(result);%0A            bufferedWriter.newLine();%0A        %7D%0A%0A        bufferedWriter.close();%0A%0A        scanner.close();%0A    %7D%0A%7D%0A

add HappyLadybugs.java