From d616ea378e493fbf6bca70a1aaee34d5b64323b2 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Sun, 19 Oct 2025 04:13:47 +0300 Subject: [PATCH] Improved tasks 430, 3044, 3426 --- .../readme.md | 33 ++++++++++++++----- .../s3044_most_frequent_prime/readme.md | 2 +- .../readme.md | 4 +-- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/g0401_0500/s0430_flatten_a_multilevel_doubly_linked_list/readme.md b/src/main/kotlin/g0401_0500/s0430_flatten_a_multilevel_doubly_linked_list/readme.md index a5b4d5f77..5f3e4790a 100644 --- a/src/main/kotlin/g0401_0500/s0430_flatten_a_multilevel_doubly_linked_list/readme.md +++ b/src/main/kotlin/g0401_0500/s0430_flatten_a_multilevel_doubly_linked_list/readme.md @@ -10,23 +10,28 @@ Return _the_ `head` _of the flattened list. The nodes in the list must have **al **Example 1:** -![](https://assets.leetcode.com/uploads/2021/11/09/flatten11.jpg) +![](https://leetcode-images.github.io/g0401_0500/s0430_flatten_a_multilevel_doubly_linked_list/flatten11.jpg) **Input:** head = [1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12] **Output:** [1,2,3,7,8,11,12,9,10,4,5,6] -**Explanation:** The multilevel linked list in the input is shown. After flattening the multilevel linked list it becomes: ![](https://assets.leetcode.com/uploads/2021/11/09/flatten12.jpg) +**Explanation:** The multilevel linked list in the input is shown. After flattening the multilevel linked list it becomes: ![](https://leetcode-images.github.io/g0401_0500/s0430_flatten_a_multilevel_doubly_linked_list/flatten12.jpg) **Example 2:** -![](https://assets.leetcode.com/uploads/2021/11/09/flatten2.1jpg) +![](https://leetcode-images.github.io/g0401_0500/s0430_flatten_a_multilevel_doubly_linked_list/flatten21.jpg) **Input:** head = [1,2,null,3] **Output:** [1,3,2] -**Explanation:** The multilevel linked list in the input is shown. After flattening the multilevel linked list it becomes: ![](https://assets.leetcode.com/uploads/2021/11/24/list.jpg) +**Explanation:** + + The multilevel linked list in the input is shown. + After flattening the multilevel linked list it becomes: + +![](https://leetcode-images.github.io/g0401_0500/s0430_flatten_a_multilevel_doubly_linked_list/list.jpg) **Example 3:** @@ -34,7 +39,7 @@ Return _the_ `head` _of the flattened list. The nodes in the list must have **al **Output:** [] -**Explanation:** There could be empty list in the input. +**Explanation:** There could be empty list in the input. **Constraints:** @@ -45,16 +50,26 @@ Return _the_ `head` _of the flattened list. The nodes in the list must have **al We use the multilevel linked list from **Example 1** above: -1---2---3---4---5---6--NULL | 7---8---9---10--NULL | 11--12--NULL + 1---2---3---4---5---6--NULL + | + 7---8---9---10--NULL + | + 11--12--NULL The serialization of each level is as follows: -[1,2,3,4,5,6,null] [7,8,9,10,null] [11,12,null] + [1,2,3,4,5,6,null] + [7,8,9,10,null] + [11,12,null] To serialize all levels together, we will add nulls in each level to signify no node connects to the upper node of the previous level. The serialization becomes: -[1, 2, 3, 4, 5, 6, null] | [null, null, 7, 8, 9, 10, null] | [ null, 11, 12, null] + [1, 2, 3, 4, 5, 6, null] + | + [null, null, 7, 8, 9, 10, null] + | + [ null, 11, 12, null] Merging the serialization of each level and removing trailing nulls we obtain: -[1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12] \ No newline at end of file + [1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12] \ No newline at end of file diff --git a/src/main/kotlin/g3001_3100/s3044_most_frequent_prime/readme.md b/src/main/kotlin/g3001_3100/s3044_most_frequent_prime/readme.md index 723d7a1e7..accac0e0b 100644 --- a/src/main/kotlin/g3001_3100/s3044_most_frequent_prime/readme.md +++ b/src/main/kotlin/g3001_3100/s3044_most_frequent_prime/readme.md @@ -14,7 +14,7 @@ Return _the most frequent prime number **greater** than_ `10` _out of all the nu **Example 1:** - **![](https://assets.leetcode.com/uploads/2024/02/15/south)** + **![](https://leetcode-images.github.io/g3001_3100/s3044_most_frequent_prime/south.png)** **Input:** mat = [[1,1],[9,9],[1,1]] diff --git a/src/main/kotlin/g3401_3500/s3426_manhattan_distances_of_all_arrangements_of_pieces/readme.md b/src/main/kotlin/g3401_3500/s3426_manhattan_distances_of_all_arrangements_of_pieces/readme.md index 4e262e62c..0b51bd8ea 100644 --- a/src/main/kotlin/g3401_3500/s3426_manhattan_distances_of_all_arrangements_of_pieces/readme.md +++ b/src/main/kotlin/g3401_3500/s3426_manhattan_distances_of_all_arrangements_of_pieces/readme.md @@ -22,7 +22,7 @@ The Manhattan Distance between two cells (xi, yi)