Skip to content

Commit

Permalink
update posts
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-jonghoonpark committed Aug 18, 2024
1 parent 2b06aa0 commit 1183994
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions _posts/2024-04-18-leetcode-347.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
---
layout: post
title: (Leetcode) 347 - Top K Frequent Elements
title: (Leetcode) 347 - Top K Frequent Elements 풀이
categories: [스터디-알고리즘]
tags: [자바, java, 스트림, stream, 리트코드, Leetcode, 알고리즘, algorithm]
tags:
[
자바,
java,
스트림,
stream,
리트코드,
Leetcode,
알고리즘,
algorithm,
map,
counting,
]
date: 2024-04-18 12:30:00 +0900
---

Expand All @@ -23,14 +35,13 @@ public int[] topKFrequent(int[] nums, int k) {
Map<Integer, Integer> counter = new HashMap<>();

Arrays.stream(nums)
.forEach(num -> {
counter.put(num, counter.getOrDefault(num, 0) + 1);
});
.forEach(num -> counter.merge(num, 1, Integer::sum));

return Arrays.copyOfRange(counter.entrySet().stream()
return counter.entrySet().stream()
.sorted(Map.Entry.<Integer, Integer>comparingByValue().reversed())
.mapToInt(Map.Entry::getKey)
.toArray(), 0, k);
.limit(k)
.toArray();
}
```

Expand Down
2 changes: 1 addition & 1 deletion _posts/2024-07-08-leetcode-91.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: post
title: (Leetcode) 647 - Decode Ways 풀이
title: (Leetcode) 91 - Decode Ways 풀이
categories: [스터디-알고리즘]
tags:
[자바, java, 리트코드, Leetcode, 알고리즘, string, dp, dynamic programming]
Expand Down

0 comments on commit 1183994

Please sign in to comment.