@@ -0,0 +1,2556 @@
+//Problem: https://www.hackerrank.com/challenges/anagram%0D%0A//Java 8%0D%0A/*%0D%0AInitial Thoughts:%0D%0AGet frequency of first and second half%0D%0ACount the changes second half needs to become first half%0D%0A%0D%0ATime complexity: O(n)   //Time equivalent to input size%0D%0ASpace complexity: O(1)  //The alphabet is limited to 26 char so maps have a constant size%0D%0A%0D%0A%0D%0A*/%0D%0Aimport java.io.*;%0D%0Aimport java.util.*;%0D%0A%0D%0Apublic class Solution %7B%0D%0A%0D%0A    public static void main(String%5B%5D args) %7B%0D%0A        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */%0D%0A        Scanner input = new Scanner(System.in);%0D%0A        int T = input.nextInt();%0D%0A        input.nextLine();%0D%0A        %0D%0A        tests:%0D%0A        for(int t = 0; t %3C T; t++)%0D%0A        %7B%0D%0A            String s = input.nextLine();%0D%0A            %0D%0A            if(s.length() %25 2 == 1)%0D%0A            %7B%0D%0A                System.out.println(-1); continue tests;%0D%0A            %7D%0D%0A            %0D%0A            %0D%0A            Map%3CCharacter,Integer%3E firstHalf = new HashMap%3C%3E();%0D%0A            Map%3CCharacter,Integer%3E secondHalf = new HashMap%3C%3E();%0D%0A            %0D%0A            //Get frequency of chars in first half%0D%0A            for(int i = 0; i %3C s.length()/2; i++)%0D%0A            %7B%0D%0A                if(firstHalf.containsKey(s.charAt(i)))%0D%0A                    firstHalf.put(s.charAt(i), firstHalf.get(s.charAt(i)) + 1);%0D%0A                else%0D%0A                    firstHalf.put(s.charAt(i), 1);%0D%0A            %7D%0D%0A                %0D%0A            //Get frequency of chars in second half%0D%0A            for(int i = s.length()/2; i %3C s.length(); i++)%0D%0A            %7B%0D%0A                if(secondHalf.containsKey(s.charAt(i)))%0D%0A                    secondHalf.put(s.charAt(i), secondHalf.get(s.charAt(i)) + 1);%0D%0A                else%0D%0A                    secondHalf.put(s.charAt(i), 1);%0D%0A            %7D%0D%0A            int operations = 0;%0D%0A            %0D%0A            //Iterate through second half determining what needs to switch to match it%0D%0A            for(Map.Entry%3CCharacter,Integer%3E letter : secondHalf.entrySet())%0D%0A            %7B%0D%0A                %0D%0A                int f2 = letter.getValue();%0D%0A                int f1 = (firstHalf.get(letter.getKey()) != null) ? firstHalf.get(letter.getKey()) : 0;%0D%0A                %0D%0A                //This is when there are not enough chars in the first half to match those in the second half%0D%0A                if(f2 %3E f1)%0D%0A                    operations += (f2 - f1);  %0D%0A                %0D%0A                %0D%0A            %7D%0D%0A            System.out.println(operations);%0D%0A        %7D%0D%0A    %7D%0D%0A%7D

Completed a String algorithm called Anagram