Skip to content

Commit 1af29b4

Browse files
add 3063
1 parent e4fe2a0 commit 1af29b4

File tree

2 files changed

+26
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src/main/java/com/fishercoder/solutions/fourththousand

2 files changed

+26
-0
lines changed

Diff for: paginated_contents/algorithms/4th_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
| 3074 | [Apple Redistribution into Boxes](https://leetcode.com/problems/apple-redistribution-into-boxes/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3074.java) | | Easy |
5757
| 3069 | [Distribute Elements Into Two Arrays I](https://leetcode.com/problems/distribute-elements-into-two-arrays-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3069.java) | | Easy |
5858
| 3065 | [Minimum Operations to Exceed Threshold Value I](https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3065.java) | | Easy |
59+
| 3063 | [Linked List Frequency](https://leetcode.com/problems/linked-list-frequency/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3063.java) | | Easy |
5960
| 3062 | [Winner of the Linked List Game](https://leetcode.com/problems/winner-of-the-linked-list-game/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3062.java) | | Easy |
6061
| 3046 | [Split the Array](https://leetcode.com/problems/split-the-array/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3046.java) | | Easy |
6162
| 3042 | [Count Prefix and Suffix Pairs I](https://leetcode.com/problems/count-prefix-and-suffix-pairs-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3042.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
import com.fishercoder.common.classes.ListNode;
4+
5+
import java.util.HashMap;
6+
import java.util.Map;
7+
8+
public class _3063 {
9+
public static class Solution1 {
10+
public ListNode frequenciesOfElements(ListNode head) {
11+
Map<Integer, Integer> map = new HashMap<>();
12+
while (head != null) {
13+
map.put(head.val, map.getOrDefault(head.val, 0) + 1);
14+
head = head.next;
15+
}
16+
ListNode pre = new ListNode(-1);
17+
ListNode tmp = pre;
18+
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
19+
tmp.next = new ListNode(entry.getValue());
20+
tmp = tmp.next;
21+
}
22+
return pre.next;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)