You are viewing a single comment's thread. Return to all comments →
I had done something similar but only two testcases pass why?
import java.util.*; import java.io.*; public class Hack45{ static PrintStream p = System.out; static int [] arr = new int[26]; public static void main(String[] args){ StringBuilder sb = new StringBuilder(); String s,s1; Scanner in = new Scanner(System.in); s = in.next(); s1 = in.next(); int i; for(i=0; i<s.length(); i++){ arr[s.charAt(i)-'a']++; } for(i=0; i<s1.length(); i++){ if(arr[s1.charAt(i)-'a']!=0) arr[s1.charAt(i)-'a']--; else arr[s1.charAt(i)-'a']++; } int count = 0; for(i=0; i<26; i++){ count+=arr[i]; } p.println(count); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Making Anagrams
You are viewing a single comment's thread. Return to all comments →
I had done something similar but only two testcases pass why?