JAVA_Most Common Word_LeetCode 819


JAVA_Most Common Word_LeetCode 819

JAVA_Most Common Word_LeetCode 819 풀이 class Solution { public String mostCommonWord(String paragraph, String[] banned) { HashMap<String, Integer> wordToCount = new HashMap<String, Integer>(); int max = 0, cnt = 0; String res = ""; HashSet<String> hashSet = new HashSet<String>(); Collections.addAll(hashSet, banned); for (String word : paragraph.toLowerCase().split("[!?;.,' ]")) { if (word.isEmpty() || hashSet.contains(word)) continue; cnt = wordToCount.compute(word, (k, v) -> (v == null) ? 1 : ++...


#JAVA #JAVA_LeetCode819 #JAVA_MostCommonWord #JAVA_MostCommonWord_LeetCode819 #MostCommonWord_LeetCode819

원문링크 : JAVA_Most Common Word_LeetCode 819