Skip to content

Commit

Permalink
update post
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-jonghoonpark committed May 29, 2024
1 parent 5e40e17 commit f289d93
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions _posts/2024-04-18-leetcode-347.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ date: 2024-04-18 12:30:00 +0900
```java
public int[] topKFrequent(int[] nums, int k) {
Map<Integer, Integer> counter = new HashMap<>();

Arrays.stream(nums)
.forEach(num -> {
Integer count = counter.get(num);
counter.put(num, count == null ? 1 : count + 1);
counter.put(num, counter.getOrDefault(num, 0) + 1);
});

return Arrays.copyOfRange(counter.entrySet().stream()
Expand Down

0 comments on commit f289d93

Please sign in to comment.