Created
October 21, 2016 12:07
-
-
Save mohitkhosla01/c6dea0259b53bc8034e87831bd4f78dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.util.ArrayList; | |
public class makingAnagrams { | |
public static void main(String[] args) { | |
Scanner sc=new Scanner(System.in); | |
String s1 = sc.next(); | |
String s2 = sc.next(); | |
ArrayList<Character> arr1 = new ArrayList<Character>(); | |
for(int i=0;i<s1.length();++i){ | |
arr1.add(s1.charAt(i)); | |
} | |
ArrayList<Character> arr2 = new ArrayList<Character>(); | |
for(int i=0;i<s2.length();++i){ | |
arr2.add(s2.charAt(i)); | |
} | |
int c=0, i=0; | |
while(i!=arr1.size()){ | |
if(arr2.contains(arr1.get(i))){ | |
arr2.remove(arr2.indexOf(arr1.get(i))); | |
arr1.remove(i); | |
} | |
else{ | |
++i; | |
} | |
} | |
System.out.println(arr1.size()+arr2.size()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment