@@ -0,0 +1,2801 @@
+package com.tacoscott.chapter01;%0A%0Aimport java.util.HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.Map;%0Aimport java.util.Set;%0A%0A/**%0A * Created by scott.powers on 3/19/17.%0A */%0Apublic class q2 %7B%0A  //Start @ 2:20pm%0A  //My re-wording of question:%0A  //  Given two strings, check to see if they both contain the same chars, in the same amounts.%0A  //Questions I would ask:%0A  //  Any limitations on character set? Standard ASCII? English chars? Unicode/etc?%0A  //  Case sensitive?%0A  //Function will return true if both strings are permutations, false if there are not%0A%0A  //First thought is to make sure the strings are the same length%0A  //Then I'd use a Map%3CCharacter,Integer%3E to maintain char counts;%0A  private static boolean firstPass(String compare1, String compare2) %7B%0A    if (compare1.length() != compare2.length()) %7B return false; %7D%0A    Map%3CCharacter,Integer%3E charCounts = new HashMap%3C%3E();%0A%0A    for (int i=0;i%3Ccompare1.length();i++) %7B%0A      Character c = compare1.charAt(i);%0A      if (charCounts.containsKey(c)) %7B%0A        int newCount = charCounts.get(c) + 1;%0A        charCounts.put(c,newCount);%0A      %7D else %7B%0A        charCounts.put(c,1);%0A      %7D%0A    %7D%0A%0A    for (int i=0;i%3Ccompare2.length(); i++) %7B%0A      Character c = compare2.charAt(i);%0A      if (charCounts.containsKey(c)) %7B%0A        int newCount = charCounts.get(c) - 1;%0A        if (newCount %3C 0) %7B return false; %7D%0A        charCounts.put(c,newCount);%0A      %7D else %7B%0A        return false;%0A      %7D%0A    %7D%0A    return true;%0A  %7D%0A%0A%0A  //End @ 2:34%0A  //Hints used: none%0A  //Thoughts before looking at solution(s):%0A  //  if we can limit the character set, similar to the 1.1, we could do this with a array of ints%0A  //  we could also sort the strings first, and then do a simple index by index comparision, but that%0A  //  seems like it would be more total operations%0A  //  otherwise, I feel like this solution is generally reasonable.%0A  //Thoughts after looking at solution(s):%0A  //  They sort the string first using char's which will fail on multibyte characters. Although I'm starting to suspect%0A  //  they generally don't care about unicode strings so may account for that first in future solutions.%0A  //  Otherwise, this is pretty close to one of my alternate ideas of comparing lengths first, sorting,%0A  //  then doing a simple comparision%0A  //  the second solution they offer is closer to mine, but they again use simpler data types/structures which I will%0A  //  consider for future solutions.%0A%0A  private static void passThru(String compare1, String compare2) %7B%0A    System.out.println(%22Comparing: %22 + compare1 + %22 -%3E %22 + compare2 + %22 : %22 + firstPass(compare1,compare2));%0A  %7D%0A%0A  public static void main(String%5B%5D args) %7B%0A    passThru(%22tacobell%22,%22dfgdfg%22);%0A    passThru(%22taco%22,%22ocat%22);%0A    passThru(%22aabbcc%22,%22bbggdd%22);%0A    passThru(%22abcd%22,%22dacb%22);%0A  %7D%0A%7D%0A

solution 1.2