diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 11a54f6..68d8045 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -69,17 +69,14 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/Anagram.java b/Anagram.java
index fb62b57..0f764f8 100644
--- a/Anagram.java
+++ b/Anagram.java
@@ -2,13 +2,27 @@
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);
+ int occurrence;
+ if (oneHM.get(c) != null) {
+ occurrence = oneHM.get(c);
+ }
+ else {
+ occurrence = 1;
+ }
+ oneHM.put(c, occurrence + 1);
}
for (char c : twoS.toCharArray()) {
- twoHM.put(c, true);
+ int occurrence;
+ if (twoHM.get(c) != null) {
+ occurrence = twoHM.get(c);
+ }
+ else {
+ occurrence = 1;
+ }
+ twoHM.put(c, occurrence + 1);
}
return oneHM.equals(twoHM);
}