We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc=new Scanner(System.in);
String s1=sc.nextLine();
String s2=sc.nextLine();
int cArr[]=new int[26];
int cArr1[]=new int[26];
for(int i=0;i<s1.length();i++)cArr[s1.charAt(i)-97]++;
for(int i=0;i<s2.length();i++)cArr1[s2.charAt(i)-97]++;
int count=0;
for(int i=0;i<26;i++)count+=Math.abs(cArr[i]-cArr1[i]);
System.out.println(count);
}
Making Anagrams
You are viewing a single comment's thread. Return to all comments →
Java implementation of the problem!!
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
}