You are viewing a single comment's thread. Return to all comments →
Here is my java solution for this
import java.util.Scanner; public class Solution { public static int numberNeeded(String first, String second) { int[] lettercounts = new int[26]; for(char c : first.toCharArray()){ lettercounts[c-'a']++; } for(char c : second.toCharArray()){ lettercounts[c-'a']--; } int result = 0; for(int i : lettercounts){ result += Math.abs(i); } return result; } public static void main(String[] args) { Scanner in = new Scanner(System.in); String a = in.next(); String b = in.next(); System.out.println(numberNeeded(a, b)); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
Here is my java solution for this