diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 11a54f6..e6f6f40 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -69,17 +69,13 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/Anagram.java b/Anagram.java
index fb62b57..1979cca 100644
--- a/Anagram.java
+++ b/Anagram.java
@@ -2,13 +2,23 @@
public class Anagram {
public static boolean anagram(String oneS, String twoS) {
- HashMap oneHM = new HashMap();
- HashMap twoHM = new HashMap();
+ HashMap oneHM = new HashMap();
+ HashMap twoHM = new HashMap();
for (char c : oneS.toCharArray()) {
- oneHM.put(c, true);
+ if (oneHM.containsKey(c)) {
+ oneHM.put(c, oneHM.get(c) + 1);
+ }
+ else
+ oneHM.put(c, 1);
}
+
for (char c : twoS.toCharArray()) {
- twoHM.put(c, true);
+ if (twoHM.containsKey(c)) {
+ twoHM.put(c, twoHM.get(c) + 1);
+
+ }
+ else
+ twoHM.put(c, 1);
}
return oneHM.equals(twoHM);
}