title: Compare hashMap values
body: <p>Im practicing some interview questions but have no idea how to compare hashMap values. The premise is that you have a magazine with strings. You have to cut out the appropriate number of  characters out of the magazine to form a ransom note. I've managed to add both the characters and the number of occurrences of the characters to a hashMap but how do I compare the two hashMaps to determine I have enough letters.Any guidance would be much appreciated.</p>
  
  <p>Magazine = {g=2,  =14, d=2, e=2, a=4, n=1, o=5, l=4, m=1, .=1, k=1, I=2, h=2, i=6, w=1, T=1, u=1, t=2, s=3, r=1, y=2}
  Ransom = {w=1,  =3, o=1, l=4, k=1, I=1, y=1, i=2}</p>
  
  <pre><code>String mag = "this is what I said Im going to do. i really like you a lot";
          String ransom = "i will kill you";
  
          Map&lt;Character,Integer&gt; map = new HashMap&lt;Character,Integer&gt;();
          Map&lt;Character,Integer&gt; ransomMap = new HashMap&lt;Character,Integer&gt;();
  
          for(int i = 0; i &lt; mag.length() -1; i++)
          {
              char c = mag.charAt(i);
              if(!map.containsKey(c))
              map.put(c, 1);
              else{
                  int value = map.get(c);
                  map.put(c,++value);
              }
          }
  
          System.out.println(map);
  
          for(int i = 0; i &lt; ransom.length()-1; i++ )
          {
          char c = ransom.charAt(i);
          if(!ransomMap.containsKey(c))
              ransomMap.put(c,1);
          else
          {
              int value = (ransomMap.get(c));
              ransomMap.put(c,++value);
          }
          }
          System.out.println(ransomMap);
      }
  </code></pre>