diff --git a/solution/3000-3099/3061.Calculate Trapping Rain Water/README.md b/solution/3000-3099/3061.Calculate Trapping Rain Water/README.md
index a250a21aab26a..1f12b3962a790 100644
--- a/solution/3000-3099/3061.Calculate Trapping Rain Water/README.md
+++ b/solution/3000-3099/3061.Calculate Trapping Rain Water/README.md
@@ -56,7 +56,7 @@ Heights table:
| 6 |
+---------------------+
Explanation:
-
+
The elevation map depicted above (in the black section) is graphically represented with the x-axis denoting the id and the y-axis representing the heights [0,1,0,2,1,0,1,3,2,1,2,1]. In this scenario, 6 units of rainwater are trapped within the blue section.
diff --git a/solution/3000-3099/3061.Calculate Trapping Rain Water/README_EN.md b/solution/3000-3099/3061.Calculate Trapping Rain Water/README_EN.md
index 2b833305b9b66..2a388d99b838e 100644
--- a/solution/3000-3099/3061.Calculate Trapping Rain Water/README_EN.md
+++ b/solution/3000-3099/3061.Calculate Trapping Rain Water/README_EN.md
@@ -54,7 +54,7 @@ Heights table:
| 6 |
+---------------------+
Explanation:
-
+
The elevation map depicted above (in the black section) is graphically represented with the x-axis denoting the id and the y-axis representing the heights [0,1,0,2,1,0,1,3,2,1,2,1]. In this scenario, 6 units of rainwater are trapped within the blue section.
diff --git a/solution/3000-3099/3061.Calculate Trapping Rain Water/images/trapping_rain_water.png b/solution/3000-3099/3061.Calculate Trapping Rain Water/images/trapping_rain_water.png
new file mode 100644
index 0000000000000..0b30471593af8
Binary files /dev/null and b/solution/3000-3099/3061.Calculate Trapping Rain Water/images/trapping_rain_water.png differ
diff --git a/solution/3000-3099/3062.Winner of the Linked List Game/README.md b/solution/3000-3099/3062.Winner of the Linked List Game/README.md
index 71a3c5bf64339..28b2b32725087 100644
--- a/solution/3000-3099/3062.Winner of the Linked List Game/README.md
+++ b/solution/3000-3099/3062.Winner of the Linked List Game/README.md
@@ -87,24 +87,156 @@
## 解法
-### 方法一
+### 方法一:模拟
+
+遍历链表,每次取出两个节点,比较它们的值,然后根据比较结果更新奇数和偶数的得分。最后比较奇数和偶数的得分,返回结果。
+
+时间复杂度 $O(n)$,其中 $n$ 是链表的长度。空间复杂度 $O(1)$。
```python
-
+# Definition for singly-linked list.
+# class ListNode:
+# def __init__(self, val=0, next=None):
+# self.val = val
+# self.next = next
+class Solution:
+ def gameResult(self, head: Optional[ListNode]) -> str:
+ odd = even = 0
+ while head:
+ a = head.val
+ b = head.next.val
+ odd += a < b
+ even += a > b
+ head = head.next.next
+ if odd > even:
+ return "Odd"
+ if odd < even:
+ return "Even"
+ return "Tie"
```
```java
-
+/**
+ * Definition for singly-linked list.
+ * public class ListNode {
+ * int val;
+ * ListNode next;
+ * ListNode() {}
+ * ListNode(int val) { this.val = val; }
+ * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
+ * }
+ */
+class Solution {
+ public String gameResult(ListNode head) {
+ int odd = 0, even = 0;
+ for (; head != null; head = head.next.next) {
+ int a = head.val;
+ int b = head.next.val;
+ odd += a < b ? 1 : 0;
+ even += a > b ? 1 : 0;
+ }
+ if (odd > even) {
+ return "Odd";
+ }
+ if (odd < even) {
+ return "Even";
+ }
+ return "Tie";
+ }
+}
```
```cpp
-
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ * int val;
+ * ListNode *next;
+ * ListNode() : val(0), next(nullptr) {}
+ * ListNode(int x) : val(x), next(nullptr) {}
+ * ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+ string gameResult(ListNode* head) {
+ int odd = 0, even = 0;
+ for (; head != nullptr; head = head->next->next) {
+ int a = head->val;
+ int b = head->next->val;
+ odd += a < b;
+ even += a > b;
+ }
+ if (odd > even) {
+ return "Odd";
+ }
+ if (odd < even) {
+ return "Even";
+ }
+ return "Tie";
+ }
+};
```
```go
+/**
+ * Definition for singly-linked list.
+ * type ListNode struct {
+ * Val int
+ * Next *ListNode
+ * }
+ */
+func gameResult(head *ListNode) string {
+ var odd, even int
+ for ; head != nil; head = head.Next.Next {
+ a, b := head.Val, head.Next.Val
+ if a < b {
+ odd++
+ }
+ if a > b {
+ even++
+ }
+ }
+ if odd > even {
+ return "Odd"
+ }
+ if odd < even {
+ return "Even"
+ }
+ return "Tie"
+}
+```
+```ts
+/**
+ * Definition for singly-linked list.
+ * class ListNode {
+ * val: number
+ * next: ListNode | null
+ * constructor(val?: number, next?: ListNode | null) {
+ * this.val = (val===undefined ? 0 : val)
+ * this.next = (next===undefined ? null : next)
+ * }
+ * }
+ */
+
+function gameResult(head: ListNode | null): string {
+ let [odd, even] = [0, 0];
+ for (; head; head = head.next.next) {
+ const [a, b] = [head.val, head.next.val];
+ odd += a < b ? 1 : 0;
+ even += a > b ? 1 : 0;
+ }
+ if (odd > even) {
+ return 'Odd';
+ }
+ if (odd < even) {
+ return 'Even';
+ }
+ return 'Tie';
+}
```
diff --git a/solution/3000-3099/3062.Winner of the Linked List Game/README_EN.md b/solution/3000-3099/3062.Winner of the Linked List Game/README_EN.md
index fbb0c93e306d9..eb75c4e2afb8a 100644
--- a/solution/3000-3099/3062.Winner of the Linked List Game/README_EN.md
+++ b/solution/3000-3099/3062.Winner of the Linked List Game/README_EN.md
@@ -85,24 +85,156 @@
## Solutions
-### Solution 1
+### Solution 1: Simulation
+
+Traverse the linked list, each time taking out two nodes, compare their values, and then update the scores of odd and even numbers based on the comparison results. Finally, compare the scores of odd and even numbers and return the result.
+
+The time complexity is $O(n)$, where $n$ is the length of the linked list. The space complexity is $O(1)$.
```python
-
+# Definition for singly-linked list.
+# class ListNode:
+# def __init__(self, val=0, next=None):
+# self.val = val
+# self.next = next
+class Solution:
+ def gameResult(self, head: Optional[ListNode]) -> str:
+ odd = even = 0
+ while head:
+ a = head.val
+ b = head.next.val
+ odd += a < b
+ even += a > b
+ head = head.next.next
+ if odd > even:
+ return "Odd"
+ if odd < even:
+ return "Even"
+ return "Tie"
```
```java
-
+/**
+ * Definition for singly-linked list.
+ * public class ListNode {
+ * int val;
+ * ListNode next;
+ * ListNode() {}
+ * ListNode(int val) { this.val = val; }
+ * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
+ * }
+ */
+class Solution {
+ public String gameResult(ListNode head) {
+ int odd = 0, even = 0;
+ for (; head != null; head = head.next.next) {
+ int a = head.val;
+ int b = head.next.val;
+ odd += a < b ? 1 : 0;
+ even += a > b ? 1 : 0;
+ }
+ if (odd > even) {
+ return "Odd";
+ }
+ if (odd < even) {
+ return "Even";
+ }
+ return "Tie";
+ }
+}
```
```cpp
-
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ * int val;
+ * ListNode *next;
+ * ListNode() : val(0), next(nullptr) {}
+ * ListNode(int x) : val(x), next(nullptr) {}
+ * ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+ string gameResult(ListNode* head) {
+ int odd = 0, even = 0;
+ for (; head != nullptr; head = head->next->next) {
+ int a = head->val;
+ int b = head->next->val;
+ odd += a < b;
+ even += a > b;
+ }
+ if (odd > even) {
+ return "Odd";
+ }
+ if (odd < even) {
+ return "Even";
+ }
+ return "Tie";
+ }
+};
```
```go
+/**
+ * Definition for singly-linked list.
+ * type ListNode struct {
+ * Val int
+ * Next *ListNode
+ * }
+ */
+func gameResult(head *ListNode) string {
+ var odd, even int
+ for ; head != nil; head = head.Next.Next {
+ a, b := head.Val, head.Next.Val
+ if a < b {
+ odd++
+ }
+ if a > b {
+ even++
+ }
+ }
+ if odd > even {
+ return "Odd"
+ }
+ if odd < even {
+ return "Even"
+ }
+ return "Tie"
+}
+```
+```ts
+/**
+ * Definition for singly-linked list.
+ * class ListNode {
+ * val: number
+ * next: ListNode | null
+ * constructor(val?: number, next?: ListNode | null) {
+ * this.val = (val===undefined ? 0 : val)
+ * this.next = (next===undefined ? null : next)
+ * }
+ * }
+ */
+
+function gameResult(head: ListNode | null): string {
+ let [odd, even] = [0, 0];
+ for (; head; head = head.next.next) {
+ const [a, b] = [head.val, head.next.val];
+ odd += a < b ? 1 : 0;
+ even += a > b ? 1 : 0;
+ }
+ if (odd > even) {
+ return 'Odd';
+ }
+ if (odd < even) {
+ return 'Even';
+ }
+ return 'Tie';
+}
```
diff --git a/solution/3000-3099/3062.Winner of the Linked List Game/Solution.cpp b/solution/3000-3099/3062.Winner of the Linked List Game/Solution.cpp
new file mode 100644
index 0000000000000..d64c5f77328ad
--- /dev/null
+++ b/solution/3000-3099/3062.Winner of the Linked List Game/Solution.cpp
@@ -0,0 +1,29 @@
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ * int val;
+ * ListNode *next;
+ * ListNode() : val(0), next(nullptr) {}
+ * ListNode(int x) : val(x), next(nullptr) {}
+ * ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+ string gameResult(ListNode* head) {
+ int odd = 0, even = 0;
+ for (; head != nullptr; head = head->next->next) {
+ int a = head->val;
+ int b = head->next->val;
+ odd += a < b;
+ even += a > b;
+ }
+ if (odd > even) {
+ return "Odd";
+ }
+ if (odd < even) {
+ return "Even";
+ }
+ return "Tie";
+ }
+};
\ No newline at end of file
diff --git a/solution/3000-3099/3062.Winner of the Linked List Game/Solution.go b/solution/3000-3099/3062.Winner of the Linked List Game/Solution.go
new file mode 100644
index 0000000000000..04affdb5e05f8
--- /dev/null
+++ b/solution/3000-3099/3062.Winner of the Linked List Game/Solution.go
@@ -0,0 +1,26 @@
+/**
+ * Definition for singly-linked list.
+ * type ListNode struct {
+ * Val int
+ * Next *ListNode
+ * }
+ */
+func gameResult(head *ListNode) string {
+ var odd, even int
+ for ; head != nil; head = head.Next.Next {
+ a, b := head.Val, head.Next.Val
+ if a < b {
+ odd++
+ }
+ if a > b {
+ even++
+ }
+ }
+ if odd > even {
+ return "Odd"
+ }
+ if odd < even {
+ return "Even"
+ }
+ return "Tie"
+}
\ No newline at end of file
diff --git a/solution/3000-3099/3062.Winner of the Linked List Game/Solution.java b/solution/3000-3099/3062.Winner of the Linked List Game/Solution.java
new file mode 100644
index 0000000000000..5af1db99c709f
--- /dev/null
+++ b/solution/3000-3099/3062.Winner of the Linked List Game/Solution.java
@@ -0,0 +1,28 @@
+/**
+ * Definition for singly-linked list.
+ * public class ListNode {
+ * int val;
+ * ListNode next;
+ * ListNode() {}
+ * ListNode(int val) { this.val = val; }
+ * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
+ * }
+ */
+class Solution {
+ public String gameResult(ListNode head) {
+ int odd = 0, even = 0;
+ for (; head != null; head = head.next.next) {
+ int a = head.val;
+ int b = head.next.val;
+ odd += a < b ? 1 : 0;
+ even += a > b ? 1 : 0;
+ }
+ if (odd > even) {
+ return "Odd";
+ }
+ if (odd < even) {
+ return "Even";
+ }
+ return "Tie";
+ }
+}
\ No newline at end of file
diff --git a/solution/3000-3099/3062.Winner of the Linked List Game/Solution.py b/solution/3000-3099/3062.Winner of the Linked List Game/Solution.py
new file mode 100644
index 0000000000000..d2e93ad25c0d9
--- /dev/null
+++ b/solution/3000-3099/3062.Winner of the Linked List Game/Solution.py
@@ -0,0 +1,19 @@
+# Definition for singly-linked list.
+# class ListNode:
+# def __init__(self, val=0, next=None):
+# self.val = val
+# self.next = next
+class Solution:
+ def gameResult(self, head: Optional[ListNode]) -> str:
+ odd = even = 0
+ while head:
+ a = head.val
+ b = head.next.val
+ odd += a < b
+ even += a > b
+ head = head.next.next
+ if odd > even:
+ return "Odd"
+ if odd < even:
+ return "Even"
+ return "Tie"
diff --git a/solution/3000-3099/3062.Winner of the Linked List Game/Solution.ts b/solution/3000-3099/3062.Winner of the Linked List Game/Solution.ts
new file mode 100644
index 0000000000000..cc68c403beb69
--- /dev/null
+++ b/solution/3000-3099/3062.Winner of the Linked List Game/Solution.ts
@@ -0,0 +1,27 @@
+/**
+ * Definition for singly-linked list.
+ * class ListNode {
+ * val: number
+ * next: ListNode | null
+ * constructor(val?: number, next?: ListNode | null) {
+ * this.val = (val===undefined ? 0 : val)
+ * this.next = (next===undefined ? null : next)
+ * }
+ * }
+ */
+
+function gameResult(head: ListNode | null): string {
+ let [odd, even] = [0, 0];
+ for (; head; head = head.next.next) {
+ const [a, b] = [head.val, head.next.val];
+ odd += a < b ? 1 : 0;
+ even += a > b ? 1 : 0;
+ }
+ if (odd > even) {
+ return 'Odd';
+ }
+ if (odd < even) {
+ return 'Even';
+ }
+ return 'Tie';
+}
diff --git a/solution/3000-3099/3063.Linked List Frequency/README.md b/solution/3000-3099/3063.Linked List Frequency/README.md
index a9acbccebf6dd..73cb2285682f8 100644
--- a/solution/3000-3099/3063.Linked List Frequency/README.md
+++ b/solution/3000-3099/3063.Linked List Frequency/README.md
@@ -53,24 +53,130 @@
## 解法
-### 方法一
+### 方法一:哈希表
+
+我们用一个哈希表 $cnt$ 记录链表中每个元素值出现的次数,然后再遍历哈希表的值构造新的链表即可。
+
+时间复杂度 $O(n)$,空间复杂度 $O(n)$。其中 $n$ 为链表的长度。
```python
-
+# Definition for singly-linked list.
+# class ListNode:
+# def __init__(self, val=0, next=None):
+# self.val = val
+# self.next = next
+class Solution:
+ def frequenciesOfElements(self, head: Optional[ListNode]) -> Optional[ListNode]:
+ cnt = Counter()
+ while head:
+ cnt[head.val] += 1
+ head = head.next
+ dummy = ListNode()
+ for val in cnt.values():
+ dummy.next = ListNode(val, dummy.next)
+ return dummy.next
```
```java
-
+/**
+ * Definition for singly-linked list.
+ * public class ListNode {
+ * int val;
+ * ListNode next;
+ * ListNode() {}
+ * ListNode(int val) { this.val = val; }
+ * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
+ * }
+ */
+class Solution {
+ public ListNode frequenciesOfElements(ListNode head) {
+ Map cnt = new HashMap<>();
+ for (; head != null; head = head.next) {
+ cnt.merge(head.val, 1, Integer::sum);
+ }
+ ListNode dummy = new ListNode();
+ for (int val : cnt.values()) {
+ dummy.next = new ListNode(val, dummy.next);
+ }
+ return dummy.next;
+ }
+}
```
```cpp
-
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ * int val;
+ * ListNode *next;
+ * ListNode() : val(0), next(nullptr) {}
+ * ListNode(int x) : val(x), next(nullptr) {}
+ * ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+ ListNode* frequenciesOfElements(ListNode* head) {
+ unordered_map cnt;
+ for (; head; head = head->next) {
+ cnt[head->val]++;
+ }
+ ListNode* dummy = new ListNode();
+ for (auto& [_, val] : cnt) {
+ dummy->next = new ListNode(val, dummy->next);
+ }
+ return dummy->next;
+ }
+};
```
```go
+/**
+ * Definition for singly-linked list.
+ * type ListNode struct {
+ * Val int
+ * Next *ListNode
+ * }
+ */
+func frequenciesOfElements(head *ListNode) *ListNode {
+ cnt := map[int]int{}
+ for ; head != nil; head = head.Next {
+ cnt[head.Val]++
+ }
+ dummy := &ListNode{}
+ for _, val := range cnt {
+ dummy.Next = &ListNode{val, dummy.Next}
+ }
+ return dummy.Next
+}
+```
+```ts
+/**
+ * Definition for singly-linked list.
+ * class ListNode {
+ * val: number
+ * next: ListNode | null
+ * constructor(val?: number, next?: ListNode | null) {
+ * this.val = (val===undefined ? 0 : val)
+ * this.next = (next===undefined ? null : next)
+ * }
+ * }
+ */
+
+function frequenciesOfElements(head: ListNode | null): ListNode | null {
+ const cnt: Map = new Map();
+ for (; head; head = head.next) {
+ cnt.set(head.val, (cnt.get(head.val) || 0) + 1);
+ }
+ const dummy = new ListNode();
+ for (const val of cnt.values()) {
+ dummy.next = new ListNode(val, dummy.next);
+ }
+ return dummy.next;
+}
```
diff --git a/solution/3000-3099/3063.Linked List Frequency/README_EN.md b/solution/3000-3099/3063.Linked List Frequency/README_EN.md
index d62e678bfa743..e1bb577d4cc6f 100644
--- a/solution/3000-3099/3063.Linked List Frequency/README_EN.md
+++ b/solution/3000-3099/3063.Linked List Frequency/README_EN.md
@@ -51,24 +51,130 @@
## Solutions
-### Solution 1
+### Solution 1: Hash Table
+
+We use a hash table `cnt` to record the occurrence times of each element value in the linked list, then traverse the values of the hash table to construct a new linked list.
+
+The time complexity is $O(n)$, and the space complexity is $O(n)$, where $n$ is the length of the linked list.
```python
-
+# Definition for singly-linked list.
+# class ListNode:
+# def __init__(self, val=0, next=None):
+# self.val = val
+# self.next = next
+class Solution:
+ def frequenciesOfElements(self, head: Optional[ListNode]) -> Optional[ListNode]:
+ cnt = Counter()
+ while head:
+ cnt[head.val] += 1
+ head = head.next
+ dummy = ListNode()
+ for val in cnt.values():
+ dummy.next = ListNode(val, dummy.next)
+ return dummy.next
```
```java
-
+/**
+ * Definition for singly-linked list.
+ * public class ListNode {
+ * int val;
+ * ListNode next;
+ * ListNode() {}
+ * ListNode(int val) { this.val = val; }
+ * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
+ * }
+ */
+class Solution {
+ public ListNode frequenciesOfElements(ListNode head) {
+ Map cnt = new HashMap<>();
+ for (; head != null; head = head.next) {
+ cnt.merge(head.val, 1, Integer::sum);
+ }
+ ListNode dummy = new ListNode();
+ for (int val : cnt.values()) {
+ dummy.next = new ListNode(val, dummy.next);
+ }
+ return dummy.next;
+ }
+}
```
```cpp
-
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ * int val;
+ * ListNode *next;
+ * ListNode() : val(0), next(nullptr) {}
+ * ListNode(int x) : val(x), next(nullptr) {}
+ * ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+ ListNode* frequenciesOfElements(ListNode* head) {
+ unordered_map cnt;
+ for (; head; head = head->next) {
+ cnt[head->val]++;
+ }
+ ListNode* dummy = new ListNode();
+ for (auto& [_, val] : cnt) {
+ dummy->next = new ListNode(val, dummy->next);
+ }
+ return dummy->next;
+ }
+};
```
```go
+/**
+ * Definition for singly-linked list.
+ * type ListNode struct {
+ * Val int
+ * Next *ListNode
+ * }
+ */
+func frequenciesOfElements(head *ListNode) *ListNode {
+ cnt := map[int]int{}
+ for ; head != nil; head = head.Next {
+ cnt[head.Val]++
+ }
+ dummy := &ListNode{}
+ for _, val := range cnt {
+ dummy.Next = &ListNode{val, dummy.Next}
+ }
+ return dummy.Next
+}
+```
+```ts
+/**
+ * Definition for singly-linked list.
+ * class ListNode {
+ * val: number
+ * next: ListNode | null
+ * constructor(val?: number, next?: ListNode | null) {
+ * this.val = (val===undefined ? 0 : val)
+ * this.next = (next===undefined ? null : next)
+ * }
+ * }
+ */
+
+function frequenciesOfElements(head: ListNode | null): ListNode | null {
+ const cnt: Map = new Map();
+ for (; head; head = head.next) {
+ cnt.set(head.val, (cnt.get(head.val) || 0) + 1);
+ }
+ const dummy = new ListNode();
+ for (const val of cnt.values()) {
+ dummy.next = new ListNode(val, dummy.next);
+ }
+ return dummy.next;
+}
```
diff --git a/solution/3000-3099/3063.Linked List Frequency/Solution.cpp b/solution/3000-3099/3063.Linked List Frequency/Solution.cpp
new file mode 100644
index 0000000000000..be5adbd51f0dc
--- /dev/null
+++ b/solution/3000-3099/3063.Linked List Frequency/Solution.cpp
@@ -0,0 +1,24 @@
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ * int val;
+ * ListNode *next;
+ * ListNode() : val(0), next(nullptr) {}
+ * ListNode(int x) : val(x), next(nullptr) {}
+ * ListNode(int x, ListNode *next) : val(x), next(next) {}
+ * };
+ */
+class Solution {
+public:
+ ListNode* frequenciesOfElements(ListNode* head) {
+ unordered_map cnt;
+ for (; head; head = head->next) {
+ cnt[head->val]++;
+ }
+ ListNode* dummy = new ListNode();
+ for (auto& [_, val] : cnt) {
+ dummy->next = new ListNode(val, dummy->next);
+ }
+ return dummy->next;
+ }
+};
\ No newline at end of file
diff --git a/solution/3000-3099/3063.Linked List Frequency/Solution.go b/solution/3000-3099/3063.Linked List Frequency/Solution.go
new file mode 100644
index 0000000000000..246e76bd0304d
--- /dev/null
+++ b/solution/3000-3099/3063.Linked List Frequency/Solution.go
@@ -0,0 +1,18 @@
+/**
+ * Definition for singly-linked list.
+ * type ListNode struct {
+ * Val int
+ * Next *ListNode
+ * }
+ */
+func frequenciesOfElements(head *ListNode) *ListNode {
+ cnt := map[int]int{}
+ for ; head != nil; head = head.Next {
+ cnt[head.Val]++
+ }
+ dummy := &ListNode{}
+ for _, val := range cnt {
+ dummy.Next = &ListNode{val, dummy.Next}
+ }
+ return dummy.Next
+}
\ No newline at end of file
diff --git a/solution/3000-3099/3063.Linked List Frequency/Solution.java b/solution/3000-3099/3063.Linked List Frequency/Solution.java
new file mode 100644
index 0000000000000..947fca6e4bb5b
--- /dev/null
+++ b/solution/3000-3099/3063.Linked List Frequency/Solution.java
@@ -0,0 +1,23 @@
+/**
+ * Definition for singly-linked list.
+ * public class ListNode {
+ * int val;
+ * ListNode next;
+ * ListNode() {}
+ * ListNode(int val) { this.val = val; }
+ * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
+ * }
+ */
+class Solution {
+ public ListNode frequenciesOfElements(ListNode head) {
+ Map cnt = new HashMap<>();
+ for (; head != null; head = head.next) {
+ cnt.merge(head.val, 1, Integer::sum);
+ }
+ ListNode dummy = new ListNode();
+ for (int val : cnt.values()) {
+ dummy.next = new ListNode(val, dummy.next);
+ }
+ return dummy.next;
+ }
+}
\ No newline at end of file
diff --git a/solution/3000-3099/3063.Linked List Frequency/Solution.py b/solution/3000-3099/3063.Linked List Frequency/Solution.py
new file mode 100644
index 0000000000000..6d35ac3737b93
--- /dev/null
+++ b/solution/3000-3099/3063.Linked List Frequency/Solution.py
@@ -0,0 +1,15 @@
+# Definition for singly-linked list.
+# class ListNode:
+# def __init__(self, val=0, next=None):
+# self.val = val
+# self.next = next
+class Solution:
+ def frequenciesOfElements(self, head: Optional[ListNode]) -> Optional[ListNode]:
+ cnt = Counter()
+ while head:
+ cnt[head.val] += 1
+ head = head.next
+ dummy = ListNode()
+ for val in cnt.values():
+ dummy.next = ListNode(val, dummy.next)
+ return dummy.next
diff --git a/solution/3000-3099/3063.Linked List Frequency/Solution.ts b/solution/3000-3099/3063.Linked List Frequency/Solution.ts
new file mode 100644
index 0000000000000..c6c1d2a1cfb1e
--- /dev/null
+++ b/solution/3000-3099/3063.Linked List Frequency/Solution.ts
@@ -0,0 +1,23 @@
+/**
+ * Definition for singly-linked list.
+ * class ListNode {
+ * val: number
+ * next: ListNode | null
+ * constructor(val?: number, next?: ListNode | null) {
+ * this.val = (val===undefined ? 0 : val)
+ * this.next = (next===undefined ? null : next)
+ * }
+ * }
+ */
+
+function frequenciesOfElements(head: ListNode | null): ListNode | null {
+ const cnt: Map = new Map();
+ for (; head; head = head.next) {
+ cnt.set(head.val, (cnt.get(head.val) || 0) + 1);
+ }
+ const dummy = new ListNode();
+ for (const val of cnt.values()) {
+ dummy.next = new ListNode(val, dummy.next);
+ }
+ return dummy.next;
+}