From 5bd96cb116842931bfa684dad58d70823a703272 Mon Sep 17 00:00:00 2001 From: yanglbme Date: Thu, 19 Sep 2024 08:46:51 +0800 Subject: [PATCH] feat: add solutions to lc problem: No.3294 No.3294.Convert Doubly Linked List to Array II --- .../README.md | 2 + .../README_EN.md | 2 + .../3265.Count Almost Equal Pairs I/README.md | 2 + .../README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../3271.Hash Divided String/README.md | 2 + .../3271.Hash Divided String/README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../3280.Convert Date to Binary/README.md | 2 + .../3280.Convert Date to Binary/README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../README.md | 2 + .../README_EN.md | 2 + .../README.md | 43 ++-- .../README.md | 208 ++++++++++++++++++ .../README_EN.md | 208 ++++++++++++++++++ .../Solution.cpp | 26 +++ .../Solution.go | 20 ++ .../Solution.java | 23 ++ .../Solution.py | 20 ++ .../Solution.ts | 27 +++ solution/DATABASE_README.md | 2 +- solution/README.md | 3 +- solution/README_EN.md | 1 + 43 files changed, 622 insertions(+), 23 deletions(-) create mode 100644 solution/3200-3299/3294.Convert Doubly Linked List to Array II/README.md create mode 100644 solution/3200-3299/3294.Convert Doubly Linked List to Array II/README_EN.md create mode 100644 solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.cpp create mode 100644 solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.go create mode 100644 solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.java create mode 100644 solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.py create mode 100644 solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.ts diff --git a/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README.md b/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README.md index 914a955d2916d..ca129c56ceb47 100644 --- a/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README.md +++ b/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README.md +rating: 1177 +source: 第 412 场周赛 Q1 tags: - 数组 - 数学 diff --git a/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README_EN.md b/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README_EN.md index 32619fb63aee2..f7449936fc031 100644 --- a/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README_EN.md +++ b/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README_EN.md +rating: 1177 +source: Weekly Contest 412 Q1 tags: - Array - Math diff --git a/solution/3200-3299/3265.Count Almost Equal Pairs I/README.md b/solution/3200-3299/3265.Count Almost Equal Pairs I/README.md index f019c5ca9879a..d8e0289e1316d 100644 --- a/solution/3200-3299/3265.Count Almost Equal Pairs I/README.md +++ b/solution/3200-3299/3265.Count Almost Equal Pairs I/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3265.Count%20Almost%20Equal%20Pairs%20I/README.md +rating: 1661 +source: 第 412 场周赛 Q2 tags: - 数组 - 哈希表 diff --git a/solution/3200-3299/3265.Count Almost Equal Pairs I/README_EN.md b/solution/3200-3299/3265.Count Almost Equal Pairs I/README_EN.md index 9889eb8bca69a..8e2687cbebcd5 100644 --- a/solution/3200-3299/3265.Count Almost Equal Pairs I/README_EN.md +++ b/solution/3200-3299/3265.Count Almost Equal Pairs I/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3265.Count%20Almost%20Equal%20Pairs%20I/README_EN.md +rating: 1661 +source: Weekly Contest 412 Q2 tags: - Array - Hash Table diff --git a/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README.md b/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README.md index 880dee8e29e51..a733a013ef8af 100644 --- a/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README.md +++ b/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3266.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20II/README.md +rating: 2508 +source: 第 412 场周赛 Q3 tags: - 数组 - 模拟 diff --git a/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README_EN.md b/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README_EN.md index 72c85e8af7494..c07c67da62c33 100644 --- a/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README_EN.md +++ b/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3266.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20II/README_EN.md +rating: 2508 +source: Weekly Contest 412 Q3 tags: - Array - Simulation diff --git a/solution/3200-3299/3267.Count Almost Equal Pairs II/README.md b/solution/3200-3299/3267.Count Almost Equal Pairs II/README.md index d01441c06554d..9bd7a18c496b1 100644 --- a/solution/3200-3299/3267.Count Almost Equal Pairs II/README.md +++ b/solution/3200-3299/3267.Count Almost Equal Pairs II/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3267.Count%20Almost%20Equal%20Pairs%20II/README.md +rating: 2545 +source: 第 412 场周赛 Q4 tags: - 数组 - 哈希表 diff --git a/solution/3200-3299/3267.Count Almost Equal Pairs II/README_EN.md b/solution/3200-3299/3267.Count Almost Equal Pairs II/README_EN.md index 4d02f2f9bda46..5541a40a53651 100644 --- a/solution/3200-3299/3267.Count Almost Equal Pairs II/README_EN.md +++ b/solution/3200-3299/3267.Count Almost Equal Pairs II/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3267.Count%20Almost%20Equal%20Pairs%20II/README_EN.md +rating: 2545 +source: Weekly Contest 412 Q4 tags: - Array - Hash Table diff --git a/solution/3200-3299/3270.Find the Key of the Numbers/README.md b/solution/3200-3299/3270.Find the Key of the Numbers/README.md index 7c8ca3da5655d..5f83c20b2574d 100644 --- a/solution/3200-3299/3270.Find the Key of the Numbers/README.md +++ b/solution/3200-3299/3270.Find the Key of the Numbers/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3270.Find%20the%20Key%20of%20the%20Numbers/README.md +rating: 1205 +source: 第 138 场双周赛 Q1 tags: - 数学 --- diff --git a/solution/3200-3299/3270.Find the Key of the Numbers/README_EN.md b/solution/3200-3299/3270.Find the Key of the Numbers/README_EN.md index 351be580f80c6..3ee0967aaeb48 100644 --- a/solution/3200-3299/3270.Find the Key of the Numbers/README_EN.md +++ b/solution/3200-3299/3270.Find the Key of the Numbers/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3270.Find%20the%20Key%20of%20the%20Numbers/README_EN.md +rating: 1205 +source: Biweekly Contest 138 Q1 tags: - Math --- diff --git a/solution/3200-3299/3271.Hash Divided String/README.md b/solution/3200-3299/3271.Hash Divided String/README.md index f3ac1105745fc..a56d69b38c787 100644 --- a/solution/3200-3299/3271.Hash Divided String/README.md +++ b/solution/3200-3299/3271.Hash Divided String/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3271.Hash%20Divided%20String/README.md +rating: 1292 +source: 第 138 场双周赛 Q2 tags: - 字符串 - 模拟 diff --git a/solution/3200-3299/3271.Hash Divided String/README_EN.md b/solution/3200-3299/3271.Hash Divided String/README_EN.md index 0cf7a432b25c2..9ca2130408507 100644 --- a/solution/3200-3299/3271.Hash Divided String/README_EN.md +++ b/solution/3200-3299/3271.Hash Divided String/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3271.Hash%20Divided%20String/README_EN.md +rating: 1292 +source: Biweekly Contest 138 Q2 tags: - String - Simulation diff --git a/solution/3200-3299/3272.Find the Count of Good Integers/README.md b/solution/3200-3299/3272.Find the Count of Good Integers/README.md index 58d6e965b0ef2..ae214ddeffd9d 100644 --- a/solution/3200-3299/3272.Find the Count of Good Integers/README.md +++ b/solution/3200-3299/3272.Find the Count of Good Integers/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3272.Find%20the%20Count%20of%20Good%20Integers/README.md +rating: 2382 +source: 第 138 场双周赛 Q3 tags: - 哈希表 - 数学 diff --git a/solution/3200-3299/3272.Find the Count of Good Integers/README_EN.md b/solution/3200-3299/3272.Find the Count of Good Integers/README_EN.md index 70035b20e7786..6517a87c9feb9 100644 --- a/solution/3200-3299/3272.Find the Count of Good Integers/README_EN.md +++ b/solution/3200-3299/3272.Find the Count of Good Integers/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3272.Find%20the%20Count%20of%20Good%20Integers/README_EN.md +rating: 2382 +source: Biweekly Contest 138 Q3 tags: - Hash Table - Math diff --git a/solution/3200-3299/3273.Minimum Amount of Damage Dealt to Bob/README.md b/solution/3200-3299/3273.Minimum Amount of Damage Dealt to Bob/README.md index 056bf0151e2f5..9ba6bf2d67e5d 100644 --- a/solution/3200-3299/3273.Minimum Amount of Damage Dealt to Bob/README.md +++ b/solution/3200-3299/3273.Minimum Amount of Damage Dealt to Bob/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3273.Minimum%20Amount%20of%20Damage%20Dealt%20to%20Bob/README.md +rating: 2012 +source: 第 138 场双周赛 Q4 tags: - 贪心 - 数组 diff --git a/solution/3200-3299/3273.Minimum Amount of Damage Dealt to Bob/README_EN.md b/solution/3200-3299/3273.Minimum Amount of Damage Dealt to Bob/README_EN.md index 777c541447ec7..298160160d9eb 100644 --- a/solution/3200-3299/3273.Minimum Amount of Damage Dealt to Bob/README_EN.md +++ b/solution/3200-3299/3273.Minimum Amount of Damage Dealt to Bob/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3273.Minimum%20Amount%20of%20Damage%20Dealt%20to%20Bob/README_EN.md +rating: 2012 +source: Biweekly Contest 138 Q4 tags: - Greedy - Array diff --git a/solution/3200-3299/3274.Check if Two Chessboard Squares Have the Same Color/README.md b/solution/3200-3299/3274.Check if Two Chessboard Squares Have the Same Color/README.md index 073c5282b5837..d04e5cc7c35a3 100644 --- a/solution/3200-3299/3274.Check if Two Chessboard Squares Have the Same Color/README.md +++ b/solution/3200-3299/3274.Check if Two Chessboard Squares Have the Same Color/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3274.Check%20if%20Two%20Chessboard%20Squares%20Have%20the%20Same%20Color/README.md +rating: 1162 +source: 第 413 场周赛 Q1 tags: - 数学 - 字符串 diff --git a/solution/3200-3299/3274.Check if Two Chessboard Squares Have the Same Color/README_EN.md b/solution/3200-3299/3274.Check if Two Chessboard Squares Have the Same Color/README_EN.md index b99a27dfa0857..1fed5f2b54e37 100644 --- a/solution/3200-3299/3274.Check if Two Chessboard Squares Have the Same Color/README_EN.md +++ b/solution/3200-3299/3274.Check if Two Chessboard Squares Have the Same Color/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3274.Check%20if%20Two%20Chessboard%20Squares%20Have%20the%20Same%20Color/README_EN.md +rating: 1162 +source: Weekly Contest 413 Q1 tags: - Math - String diff --git a/solution/3200-3299/3275.K-th Nearest Obstacle Queries/README.md b/solution/3200-3299/3275.K-th Nearest Obstacle Queries/README.md index fbd980ace751a..140b2e7058b62 100644 --- a/solution/3200-3299/3275.K-th Nearest Obstacle Queries/README.md +++ b/solution/3200-3299/3275.K-th Nearest Obstacle Queries/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3275.K-th%20Nearest%20Obstacle%20Queries/README.md +rating: 1419 +source: 第 413 场周赛 Q2 tags: - 数组 - 堆(优先队列) diff --git a/solution/3200-3299/3275.K-th Nearest Obstacle Queries/README_EN.md b/solution/3200-3299/3275.K-th Nearest Obstacle Queries/README_EN.md index 1cb9334599155..c36b25cae9d62 100644 --- a/solution/3200-3299/3275.K-th Nearest Obstacle Queries/README_EN.md +++ b/solution/3200-3299/3275.K-th Nearest Obstacle Queries/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3275.K-th%20Nearest%20Obstacle%20Queries/README_EN.md +rating: 1419 +source: Weekly Contest 413 Q2 tags: - Array - Heap (Priority Queue) diff --git a/solution/3200-3299/3276.Select Cells in Grid With Maximum Score/README.md b/solution/3200-3299/3276.Select Cells in Grid With Maximum Score/README.md index e865f5d71a7e0..c9b31e87ee7d5 100644 --- a/solution/3200-3299/3276.Select Cells in Grid With Maximum Score/README.md +++ b/solution/3200-3299/3276.Select Cells in Grid With Maximum Score/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3276.Select%20Cells%20in%20Grid%20With%20Maximum%20Score/README.md +rating: 2402 +source: 第 413 场周赛 Q3 tags: - 位运算 - 数组 diff --git a/solution/3200-3299/3276.Select Cells in Grid With Maximum Score/README_EN.md b/solution/3200-3299/3276.Select Cells in Grid With Maximum Score/README_EN.md index eb73ec9716089..e3fbc30e93ce7 100644 --- a/solution/3200-3299/3276.Select Cells in Grid With Maximum Score/README_EN.md +++ b/solution/3200-3299/3276.Select Cells in Grid With Maximum Score/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3276.Select%20Cells%20in%20Grid%20With%20Maximum%20Score/README_EN.md +rating: 2402 +source: Weekly Contest 413 Q3 tags: - Bit Manipulation - Array diff --git a/solution/3200-3299/3277.Maximum XOR Score Subarray Queries/README.md b/solution/3200-3299/3277.Maximum XOR Score Subarray Queries/README.md index 5339a28261699..48bdc302bfda4 100644 --- a/solution/3200-3299/3277.Maximum XOR Score Subarray Queries/README.md +++ b/solution/3200-3299/3277.Maximum XOR Score Subarray Queries/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3277.Maximum%20XOR%20Score%20Subarray%20Queries/README.md +rating: 2692 +source: 第 413 场周赛 Q4 tags: - 数组 - 动态规划 diff --git a/solution/3200-3299/3277.Maximum XOR Score Subarray Queries/README_EN.md b/solution/3200-3299/3277.Maximum XOR Score Subarray Queries/README_EN.md index e7d3954a6c8ef..c6be7f6a51500 100644 --- a/solution/3200-3299/3277.Maximum XOR Score Subarray Queries/README_EN.md +++ b/solution/3200-3299/3277.Maximum XOR Score Subarray Queries/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3277.Maximum%20XOR%20Score%20Subarray%20Queries/README_EN.md +rating: 2692 +source: Weekly Contest 413 Q4 tags: - Array - Dynamic Programming diff --git a/solution/3200-3299/3280.Convert Date to Binary/README.md b/solution/3200-3299/3280.Convert Date to Binary/README.md index 8d79033508131..af5a7f82ef7f9 100644 --- a/solution/3200-3299/3280.Convert Date to Binary/README.md +++ b/solution/3200-3299/3280.Convert Date to Binary/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3280.Convert%20Date%20to%20Binary/README.md +rating: 1205 +source: 第 414 场周赛 Q1 tags: - 数学 - 字符串 diff --git a/solution/3200-3299/3280.Convert Date to Binary/README_EN.md b/solution/3200-3299/3280.Convert Date to Binary/README_EN.md index 023800a6887e1..25e3d124d5b11 100644 --- a/solution/3200-3299/3280.Convert Date to Binary/README_EN.md +++ b/solution/3200-3299/3280.Convert Date to Binary/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3280.Convert%20Date%20to%20Binary/README_EN.md +rating: 1205 +source: Weekly Contest 414 Q1 tags: - Math - String diff --git a/solution/3200-3299/3281.Maximize Score of Numbers in Ranges/README.md b/solution/3200-3299/3281.Maximize Score of Numbers in Ranges/README.md index 54d0771938b09..694e22a058d78 100644 --- a/solution/3200-3299/3281.Maximize Score of Numbers in Ranges/README.md +++ b/solution/3200-3299/3281.Maximize Score of Numbers in Ranges/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3281.Maximize%20Score%20of%20Numbers%20in%20Ranges/README.md +rating: 1768 +source: 第 414 场周赛 Q2 tags: - 贪心 - 数组 diff --git a/solution/3200-3299/3281.Maximize Score of Numbers in Ranges/README_EN.md b/solution/3200-3299/3281.Maximize Score of Numbers in Ranges/README_EN.md index dbc17529c4c75..4304b08895add 100644 --- a/solution/3200-3299/3281.Maximize Score of Numbers in Ranges/README_EN.md +++ b/solution/3200-3299/3281.Maximize Score of Numbers in Ranges/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3281.Maximize%20Score%20of%20Numbers%20in%20Ranges/README_EN.md +rating: 1768 +source: Weekly Contest 414 Q2 tags: - Greedy - Array diff --git a/solution/3200-3299/3282.Reach End of Array With Max Score/README.md b/solution/3200-3299/3282.Reach End of Array With Max Score/README.md index 191997c856634..ea3a17dcf73bc 100644 --- a/solution/3200-3299/3282.Reach End of Array With Max Score/README.md +++ b/solution/3200-3299/3282.Reach End of Array With Max Score/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3282.Reach%20End%20of%20Array%20With%20Max%20Score/README.md +rating: 1771 +source: 第 414 场周赛 Q3 tags: - 贪心 - 数组 diff --git a/solution/3200-3299/3282.Reach End of Array With Max Score/README_EN.md b/solution/3200-3299/3282.Reach End of Array With Max Score/README_EN.md index 7e04f8d85f6d3..122cec6cdf60f 100644 --- a/solution/3200-3299/3282.Reach End of Array With Max Score/README_EN.md +++ b/solution/3200-3299/3282.Reach End of Array With Max Score/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3282.Reach%20End%20of%20Array%20With%20Max%20Score/README_EN.md +rating: 1771 +source: Weekly Contest 414 Q3 tags: - Greedy - Array diff --git a/solution/3200-3299/3283.Maximum Number of Moves to Kill All Pawns/README.md b/solution/3200-3299/3283.Maximum Number of Moves to Kill All Pawns/README.md index 4c7f1bd8f6892..9219676ec95ec 100644 --- a/solution/3200-3299/3283.Maximum Number of Moves to Kill All Pawns/README.md +++ b/solution/3200-3299/3283.Maximum Number of Moves to Kill All Pawns/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3283.Maximum%20Number%20of%20Moves%20to%20Kill%20All%20Pawns/README.md +rating: 2473 +source: 第 414 场周赛 Q4 tags: - 位运算 - 广度优先搜索 diff --git a/solution/3200-3299/3283.Maximum Number of Moves to Kill All Pawns/README_EN.md b/solution/3200-3299/3283.Maximum Number of Moves to Kill All Pawns/README_EN.md index 158bb0859eac8..77f307db3f7f1 100644 --- a/solution/3200-3299/3283.Maximum Number of Moves to Kill All Pawns/README_EN.md +++ b/solution/3200-3299/3283.Maximum Number of Moves to Kill All Pawns/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3283.Maximum%20Number%20of%20Moves%20to%20Kill%20All%20Pawns/README_EN.md +rating: 2473 +source: Weekly Contest 414 Q4 tags: - Bit Manipulation - Breadth-First Search diff --git a/solution/3200-3299/3293.Calculate Product Final Price/README.md b/solution/3200-3299/3293.Calculate Product Final Price/README.md index 605207a1ee57a..cd49fdefaac14 100644 --- a/solution/3200-3299/3293.Calculate Product Final Price/README.md +++ b/solution/3200-3299/3293.Calculate Product Final Price/README.md @@ -8,7 +8,7 @@ tags: -# [3293. Calculate Product Final Price 🔒](https://leetcode.cn/problems/calculate-product-final-price) +# [3293. 计算产品最终价格 🔒](https://leetcode.cn/problems/calculate-product-final-price) [English Version](/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README_EN.md) @@ -16,7 +16,7 @@ tags: -

Table: Products

+

表:Products

 +------------+---------+ 
@@ -26,11 +26,11 @@ tags:
 | category   | varchar |
 | price      | decimal |
 +------------+---------+
-product_id is the unique key for this table.
-Each row includes the product's ID, its category, and its price.
+product_id 是这张表的唯一主键。
+每一行包含产品的 ID,分类以及价格。
 
-

Table: Discounts

+

表:Discounts

 +------------+---------+ 
@@ -39,23 +39,24 @@ Each row includes the product's ID, its category, and its price.
 | category   | varchar |
 | discount   | int     |
 +------------+---------+
-category is the primary key for this table.
-Each row contains a product category and the percentage discount applied to that category (values range from 0 to 100).
+category 是这张表的主键。
+每一行包含有一个产品分类和该分类的折扣百分比(值的范围从 0 到 100)。
 
-

Write a solution to find the final price of each product after applying the category discount. If a product's category has no associated discount, its price remains unchanged.

+

编写一个解决方案来找到每个产品使用 分类折扣 后的 最终价格。如果一个产品分类 没有关联的折扣,它的价格保持 不变

-

Return the result table ordered by product_id in ascending order.

+

返回结果表以 product_id 升序 排序。

-

The result format is in the following example.

+

结果格式如下所示。

 

-

Example:

+ +

示例:

-

Input:

+

输入:

-

Products table:

+

Products 表:

 +------------+-------------+-------+
@@ -68,7 +69,7 @@ Each row contains a product category and the percentage discount applied to that
 +------------+-------------+-------+
   
-

Discounts table:

+

Discounts 表:

 +------------+----------+
@@ -79,7 +80,7 @@ Each row contains a product category and the percentage discount applied to that
 +------------+----------+
   
-

Output:

+

输出:

 +------------+------------+-------------+
@@ -92,15 +93,15 @@ Each row contains a product category and the percentage discount applied to that
 +------------+------------+-------------+
   
-

Explanation:

+

解释:

-Result table is ordered by product_id in ascending order.
+结果表以 product_id 升序排序。 diff --git a/solution/3200-3299/3294.Convert Doubly Linked List to Array II/README.md b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/README.md new file mode 100644 index 0000000000000..96e57f908a6f9 --- /dev/null +++ b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/README.md @@ -0,0 +1,208 @@ +--- +comments: true +difficulty: 中等 +edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3294.Convert%20Doubly%20Linked%20List%20to%20Array%20II/README.md +--- + + + +# [3294. Convert Doubly Linked List to Array II 🔒](https://leetcode.cn/problems/convert-doubly-linked-list-to-array-ii) + +[English Version](/solution/3200-3299/3294.Convert%20Doubly%20Linked%20List%20to%20Array%20II/README_EN.md) + +## 题目描述 + + + +

You are given an arbitrary node from a doubly linked list, which contains nodes that have a next pointer and a previous pointer.

+ +

Return an integer array which contains the elements of the linked list in order.

+ +

 

+

Example 1:

+ +
+

Input: head = [1,2,3,4,5], node = 5

+ +

Output: [1,2,3,4,5]

+
+ +

Example 2:

+ +
+

Input: head = [4,5,6,7,8], node = 8

+ +

Output: [4,5,6,7,8]

+
+ +

 

+

Constraints:

+ + + + + +## 解法 + + + +### 方法一:遍历链表 + +我们可以从给定的节点开始,往前遍历链表,直到遍历到头节点,然后再从头节点开始往后遍历链表,将遍历到的节点的值添加到答案数组中。 + +遍历结束后,返回答案数组即可。 + +时间复杂度 $O(n)$,其中 $n$ 为链表的节点个数。忽略答案数组的空间消耗,空间复杂度 $O(1)$。 + + + +#### Python3 + +```python +""" +# Definition for a Node. +class Node: + def __init__(self, val, prev=None, next=None): + self.val = val + self.prev = prev + self.next = next +""" + + +class Solution: + def toArray(self, node: "Optional[Node]") -> List[int]: + cur = node + while cur and cur.prev: + cur = cur.prev + ans = [] + while cur: + ans.append(cur.val) + cur = cur.next + return ans +``` + +#### Java + +```java +/* +// Definition for a Node. +class Node { + public int val; + public Node prev; + public Node next; +}; +*/ + +class Solution { + public int[] toArray(Node node) { + var cur = node; + while (cur != null && cur.prev != null) { + cur = cur.prev; + } + var ans = new ArrayList(); + while (cur != null) { + ans.add(cur.val); + cur = cur.next; + } + return ans.stream().mapToInt(i -> i).toArray(); + } +} +``` + +#### C++ + +```cpp +/** + * Definition for doubly-linked list. + * class Node { + * int val; + * Node* prev; + * Node* next; + * Node() : val(0), next(nullptr), prev(nullptr) {} + * Node(int x) : val(x), next(nullptr), prev(nullptr) {} + * Node(int x, Node *prev, Node *next) : val(x), next(next), prev(prev) {} + * }; + */ +class Solution { +public: + vector toArray(Node *node){ + Node* cur = node; + while (cur && cur->prev) { + cur = cur->prev; + } + vector ans; + while (cur) { + ans.push_back(cur->val); + cur = cur->next; + } + return ans; + } +}; +``` + +#### Go + +```go +/** + * Definition for a Node. + * type Node struct { + * Val int + * Next *Node + * Prev *Node + * } + */ + +func toArray(node *Node) (ans []int) { + cur := node + for cur != nil && cur.Prev != nil { + cur = cur.Prev + } + for cur != nil { + ans = append(ans, cur.Val) + cur = cur.Next + } + return +} +``` + +#### TypeScript + +```ts +/** + * Definition for _Node. + * class _Node { + * val: number + * prev: _Node | null + * next: _Node | null + * + * constructor(val?: number, prev? : _Node, next? : _Node) { + * this.val = (val===undefined ? 0 : val); + * this.prev = (prev===undefined ? null : prev); + * this.next = (next===undefined ? null : next); + * } + * } + */ + +function toArray(node: _Node | null): number[] { + let cur = node; + while (cur && cur.prev) { + cur = cur.prev; + } + const ans: number[] = []; + while (cur) { + ans.push(cur.val); + cur = cur.next; + } + return ans; +} +``` + + + + + + diff --git a/solution/3200-3299/3294.Convert Doubly Linked List to Array II/README_EN.md b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/README_EN.md new file mode 100644 index 0000000000000..98fe2a27d0d2f --- /dev/null +++ b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/README_EN.md @@ -0,0 +1,208 @@ +--- +comments: true +difficulty: Medium +edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3294.Convert%20Doubly%20Linked%20List%20to%20Array%20II/README_EN.md +--- + + + +# [3294. Convert Doubly Linked List to Array II 🔒](https://leetcode.com/problems/convert-doubly-linked-list-to-array-ii) + +[中文文档](/solution/3200-3299/3294.Convert%20Doubly%20Linked%20List%20to%20Array%20II/README.md) + +## Description + + + +

You are given an arbitrary node from a doubly linked list, which contains nodes that have a next pointer and a previous pointer.

+ +

Return an integer array which contains the elements of the linked list in order.

+ +

 

+

Example 1:

+ +
+

Input: head = [1,2,3,4,5], node = 5

+ +

Output: [1,2,3,4,5]

+
+ +

Example 2:

+ +
+

Input: head = [4,5,6,7,8], node = 8

+ +

Output: [4,5,6,7,8]

+
+ +

 

+

Constraints:

+ +
    +
  • The number of nodes in the given list is in the range [1, 500].
  • +
  • 1 <= Node.val <= 1000
  • +
  • All nodes have unique Node.val.
  • +
+ + + +## Solutions + + + +### Solution 1: Traverse the Linked List + +We can start from the given node and traverse the linked list backward until we reach the head node. Then, we traverse the linked list forward from the head node, adding the values of the nodes we encounter to the answer array. + +After the traversal is complete, return the answer array. + +The time complexity is $O(n)$, where $n$ is the number of nodes in the linked list. Ignoring the space consumption of the answer array, the space complexity is $O(1)$. + + + +#### Python3 + +```python +""" +# Definition for a Node. +class Node: + def __init__(self, val, prev=None, next=None): + self.val = val + self.prev = prev + self.next = next +""" + + +class Solution: + def toArray(self, node: "Optional[Node]") -> List[int]: + cur = node + while cur and cur.prev: + cur = cur.prev + ans = [] + while cur: + ans.append(cur.val) + cur = cur.next + return ans +``` + +#### Java + +```java +/* +// Definition for a Node. +class Node { + public int val; + public Node prev; + public Node next; +}; +*/ + +class Solution { + public int[] toArray(Node node) { + var cur = node; + while (cur != null && cur.prev != null) { + cur = cur.prev; + } + var ans = new ArrayList(); + while (cur != null) { + ans.add(cur.val); + cur = cur.next; + } + return ans.stream().mapToInt(i -> i).toArray(); + } +} +``` + +#### C++ + +```cpp +/** + * Definition for doubly-linked list. + * class Node { + * int val; + * Node* prev; + * Node* next; + * Node() : val(0), next(nullptr), prev(nullptr) {} + * Node(int x) : val(x), next(nullptr), prev(nullptr) {} + * Node(int x, Node *prev, Node *next) : val(x), next(next), prev(prev) {} + * }; + */ +class Solution { +public: + vector toArray(Node *node){ + Node* cur = node; + while (cur && cur->prev) { + cur = cur->prev; + } + vector ans; + while (cur) { + ans.push_back(cur->val); + cur = cur->next; + } + return ans; + } +}; +``` + +#### Go + +```go +/** + * Definition for a Node. + * type Node struct { + * Val int + * Next *Node + * Prev *Node + * } + */ + +func toArray(node *Node) (ans []int) { + cur := node + for cur != nil && cur.Prev != nil { + cur = cur.Prev + } + for cur != nil { + ans = append(ans, cur.Val) + cur = cur.Next + } + return +} +``` + +#### TypeScript + +```ts +/** + * Definition for _Node. + * class _Node { + * val: number + * prev: _Node | null + * next: _Node | null + * + * constructor(val?: number, prev? : _Node, next? : _Node) { + * this.val = (val===undefined ? 0 : val); + * this.prev = (prev===undefined ? null : prev); + * this.next = (next===undefined ? null : next); + * } + * } + */ + +function toArray(node: _Node | null): number[] { + let cur = node; + while (cur && cur.prev) { + cur = cur.prev; + } + const ans: number[] = []; + while (cur) { + ans.push(cur.val); + cur = cur.next; + } + return ans; +} +``` + + + + + + diff --git a/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.cpp b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.cpp new file mode 100644 index 0000000000000..0b16950e3498a --- /dev/null +++ b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.cpp @@ -0,0 +1,26 @@ +/** + * Definition for doubly-linked list. + * class Node { + * int val; + * Node* prev; + * Node* next; + * Node() : val(0), next(nullptr), prev(nullptr) {} + * Node(int x) : val(x), next(nullptr), prev(nullptr) {} + * Node(int x, Node *prev, Node *next) : val(x), next(next), prev(prev) {} + * }; + */ +class Solution { +public: + vector toArray(Node *node){ + Node* cur = node; + while (cur && cur->prev) { + cur = cur->prev; + } + vector ans; + while (cur) { + ans.push_back(cur->val); + cur = cur->next; + } + return ans; + } +}; diff --git a/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.go b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.go new file mode 100644 index 0000000000000..0b78caa070fed --- /dev/null +++ b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.go @@ -0,0 +1,20 @@ +/** + * Definition for a Node. + * type Node struct { + * Val int + * Next *Node + * Prev *Node + * } + */ + +func toArray(node *Node) (ans []int) { + cur := node + for cur != nil && cur.Prev != nil { + cur = cur.Prev + } + for cur != nil { + ans = append(ans, cur.Val) + cur = cur.Next + } + return +} diff --git a/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.java b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.java new file mode 100644 index 0000000000000..b1a89a618bfe6 --- /dev/null +++ b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.java @@ -0,0 +1,23 @@ +/* +// Definition for a Node. +class Node { + public int val; + public Node prev; + public Node next; +}; +*/ + +class Solution { + public int[] toArray(Node node) { + var cur = node; + while (cur != null && cur.prev != null) { + cur = cur.prev; + } + var ans = new ArrayList(); + while (cur != null) { + ans.add(cur.val); + cur = cur.next; + } + return ans.stream().mapToInt(i -> i).toArray(); + } +} diff --git a/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.py b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.py new file mode 100644 index 0000000000000..da1b8def752d8 --- /dev/null +++ b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.py @@ -0,0 +1,20 @@ +""" +# Definition for a Node. +class Node: + def __init__(self, val, prev=None, next=None): + self.val = val + self.prev = prev + self.next = next +""" + + +class Solution: + def toArray(self, node: "Optional[Node]") -> List[int]: + cur = node + while cur and cur.prev: + cur = cur.prev + ans = [] + while cur: + ans.append(cur.val) + cur = cur.next + return ans diff --git a/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.ts b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.ts new file mode 100644 index 0000000000000..d9b17f1588fcb --- /dev/null +++ b/solution/3200-3299/3294.Convert Doubly Linked List to Array II/Solution.ts @@ -0,0 +1,27 @@ +/** + * Definition for _Node. + * class _Node { + * val: number + * prev: _Node | null + * next: _Node | null + * + * constructor(val?: number, prev? : _Node, next? : _Node) { + * this.val = (val===undefined ? 0 : val); + * this.prev = (prev===undefined ? null : prev); + * this.next = (next===undefined ? null : next); + * } + * } + */ + +function toArray(node: _Node | null): number[] { + let cur = node; + while (cur && cur.prev) { + cur = cur.prev; + } + const ans: number[] = []; + while (cur) { + ans.push(cur.val); + cur = cur.next; + } + return ans; +} diff --git a/solution/DATABASE_README.md b/solution/DATABASE_README.md index 785c22ce47572..7e91670428b9a 100644 --- a/solution/DATABASE_README.md +++ b/solution/DATABASE_README.md @@ -295,7 +295,7 @@ | 3262 | [查找重叠的班次](/solution/3200-3299/3262.Find%20Overlapping%20Shifts/README.md) | `数据库` | 中等 | 🔒 | | 3268 | [查找重叠的班次 II](/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README.md) | `数据库` | 困难 | 🔒 | | 3278 | [寻找数据科学家职位的候选人 II](/solution/3200-3299/3278.Find%20Candidates%20for%20Data%20Scientist%20Position%20II/README.md) | `数据库` | 中等 | 🔒 | -| 3293 | [Calculate Product Final Price](/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README.md) | `数据库` | 中等 | 🔒 | +| 3293 | [计算产品最终价格](/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README.md) | `数据库` | 中等 | 🔒 | ## 版权 diff --git a/solution/README.md b/solution/README.md index 1a5934228992a..e9f8a7ddfe400 100644 --- a/solution/README.md +++ b/solution/README.md @@ -3303,7 +3303,8 @@ | 3290 | [最高乘法得分](/solution/3200-3299/3290.Maximum%20Multiplication%20Score/README.md) | `数组`,`动态规划` | 中等 | 第 415 场周赛 | | 3291 | [形成目标字符串需要的最少字符串数 I](/solution/3200-3299/3291.Minimum%20Number%20of%20Valid%20Strings%20to%20Form%20Target%20I/README.md) | `字典树`,`线段树`,`数组`,`字符串`,`二分查找`,`动态规划`,`字符串匹配`,`哈希函数`,`滚动哈希` | 中等 | 第 415 场周赛 | | 3292 | [形成目标字符串需要的最少字符串数 II](/solution/3200-3299/3292.Minimum%20Number%20of%20Valid%20Strings%20to%20Form%20Target%20II/README.md) | `线段树`,`数组`,`字符串`,`二分查找`,`动态规划`,`字符串匹配`,`哈希函数`,`滚动哈希` | 困难 | 第 415 场周赛 | -| 3293 | [Calculate Product Final Price](/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README.md) | `数据库` | 中等 | 🔒 | +| 3293 | [计算产品最终价格](/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README.md) | `数据库` | 中等 | 🔒 | +| 3294 | [Convert Doubly Linked List to Array II](/solution/3200-3299/3294.Convert%20Doubly%20Linked%20List%20to%20Array%20II/README.md) | | 中等 | 🔒 | ## 版权 diff --git a/solution/README_EN.md b/solution/README_EN.md index 446b646672327..8f752f935c685 100644 --- a/solution/README_EN.md +++ b/solution/README_EN.md @@ -3302,6 +3302,7 @@ Press Control + F(or Command + F on | 3291 | [Minimum Number of Valid Strings to Form Target I](/solution/3200-3299/3291.Minimum%20Number%20of%20Valid%20Strings%20to%20Form%20Target%20I/README_EN.md) | `Trie`,`Segment Tree`,`Array`,`String`,`Binary Search`,`Dynamic Programming`,`String Matching`,`Hash Function`,`Rolling Hash` | Medium | Weekly Contest 415 | | 3292 | [Minimum Number of Valid Strings to Form Target II](/solution/3200-3299/3292.Minimum%20Number%20of%20Valid%20Strings%20to%20Form%20Target%20II/README_EN.md) | `Segment Tree`,`Array`,`String`,`Binary Search`,`Dynamic Programming`,`String Matching`,`Hash Function`,`Rolling Hash` | Hard | Weekly Contest 415 | | 3293 | [Calculate Product Final Price](/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README_EN.md) | `Database` | Medium | 🔒 | +| 3294 | [Convert Doubly Linked List to Array II](/solution/3200-3299/3294.Convert%20Doubly%20Linked%20List%20to%20Array%20II/README_EN.md) | | Medium | 🔒 | ## Copyright