You are viewing a single comment's thread. Return to all comments →
Here it is Java Code:
import java.util.*;
class Solution{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String s = sc.nextLine(); System.out.println(got(s));
} public static String got(String s){ char[] ar = s.toCharArray(); Arrays.sort(ar); int i =0; int errorcount=0; while(i<ar.length){ if(i<ar.length-1 && ar[i]==ar[i+1]){ i=i+2; } else{ i++; errorcount++; } } if(errorcount <= 1){ return "YES"; } else{ return "NO"; } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Thrones - I
You are viewing a single comment's thread. Return to all comments →
Here it is Java Code:
import java.util.*;
class Solution{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String s = sc.nextLine(); System.out.println(got(s));
}