Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbfe8be4

Browse files
authored
Merge pull requestneetcode-gh#323 from confidencepm/patch-1
Update 49-Group-Anagrams.java
2 parentsed259ed +bc273ea commitbfe8be4

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
Stringstr=newString(hash);
12-
if(map.get(str)==null){
13-
map.put(str,newArrayList<>());
14-
}
12+
map.computeIfAbsent(str,k ->newArrayList<>());
1513
map.get(str).add(s);
1614
}
1715
res.addAll(map.values());
1816
returnres;
1917
}
20-
}
18+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp