Skip to content

Instantly share code, notes, and snippets.

@edopelawi
Created June 6, 2015 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edopelawi/779126c76733eecc987c to your computer and use it in GitHub Desktop.
Save edopelawi/779126c76733eecc987c to your computer and use it in GitHub Desktop.
Clean code
public Integer deltaValueWithText(String anotherText) {
HashMap<Character, Integer> anotherTextCharacterCount = new HashMap<Character, Integer>();
Integer delta = 0;
for (Character character : anotherText.toCharArray()) {
Integer count = anotherTextCharacterCount.get(character);
count++;
anotherTextCharacterCount.put(character,count);
}
for (Character character : anotherTextCharacterCount.keySet()) {
Integer currentTextCount = characterCount.get(character);
Integer anotherTextCount = anotherTextCharacterCount.get(character);
delta += (anotherTextCount-currentTextCount);
}
return delta;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment