@@ -0,0 +1,840 @@
+package java_problems.beginner;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0Apublic class PieceOfCake %7B%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%09%09%0D%0A%09%09Scanner sc = new Scanner(System.in);%0D%0A%09%09int numCases = Integer.parseInt(sc.nextLine());%0D%0A%09%09for (int i = 0; i %3C numCases; i++) %7B%0D%0A%09%09%09int count = 0;%0D%0A%09%09%09int max = 0;%0D%0A%09%09%09char temp;%0D%0A%09%09%09char%5B%5D arr = sc.nextLine().toCharArray();%0D%0A%09%09%09%0D%0A%09%09%09if (arr.length %25 2 == 1) %7B%0D%0A%09%09%09%09System.out.println(%22NO%22);%0D%0A%09%09%09%09continue;%0D%0A%09%09%09%7D%0D%0A%09%09%09%0D%0A%09%09%09for (int j = 0; j %3C arr.length; j++) %7B%0D%0A%09%09%09%09count = 0;%0D%0A%09%09%09%09temp = arr%5Bj%5D;%0D%0A%09%09%09%09for (int k = 0; k %3C arr.length; k++) %7B%0D%0A%09%09%09%09%09if (temp == arr%5Bk%5D) %7B%0D%0A%09%09%09%09%09%09count++;%0D%0A%09%09%09%09%09%7D%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%09if (count %3E max) %7B%0D%0A%09%09%09%09%09max = count;%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A%09%09%09if (max == arr.length / 2) %7B%0D%0A%09%09%09%09System.out.println(%22YES%22);%0D%0A%09%09%09%7D else %7B%0D%0A%09%09%09%09System.out.println(%22NO%22);%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09sc.close();%0D%0A%09%7D%0D%0A%7D

Add PieceOfCake