Created
April 28, 2021 07:02
-
-
Save tremaineeto/4da3db39aa14a9dc53c372f4df4ad5e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void keepCountOfCharactersInStringWithGetOrDefault(String str) { | |
HashMap<Character, Integer> map = new HashMap<>(); | |
for (int i = 0; i < str.length(); i++) { | |
map.put(str.charAt(i), map.getOrDefault(str.charAt(i), 0) + 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment