Skip to content

Commit bfe8be4

Browse files
authored
Merge pull request neetcode-gh#323 from confidencepm/patch-1
Update 49-Group-Anagrams.java
2 parents ed259ed + bc273ea commit bfe8be4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

java/49-Group-Anagrams.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ public List<List<String>> groupAnagrams(String[] strs) {
99
hash[c-'a']++;
1010
}
1111
String str=new String(hash);
12-
if(map.get(str)==null){
13-
map.put(str, new ArrayList<>());
14-
}
12+
map.computeIfAbsent(str, k -> new ArrayList<>());
1513
map.get(str).add(s);
1614
}
1715
res.addAll(map.values());
1816
return res;
1917
}
20-
}
18+
}

0 commit comments

Comments
 (0)