chore: update lc problems (#3533)

This commit is contained in:
Libin YANG 2024-09-18 10:30:03 +08:00 committed by GitHub
parent 3ae053dd54
commit 45adcec858
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
39 changed files with 560 additions and 88 deletions

View File

@ -20,7 +20,7 @@ tags:
<p>给你两个整数 <code>x</code><code>y</code>,计算并返回它们之间的汉明距离。</p>
<p> </p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
@ -41,14 +41,18 @@ tags:
<strong>输出:</strong>1
</pre>
<p> </p>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 <= x, y <= 2<sup>31</sup> - 1</code></li>
<li><code>0 &lt;=&nbsp;x, y &lt;= 2<sup>31</sup> - 1</code></li>
</ul>
<p>&nbsp;</p>
<p><strong>注意:</strong>本题与&nbsp;<a href="https://leetcode.cn/problems/minimum-bit-flips-to-convert-number/">2220. 转换数字的最少位翻转次数</a>&nbsp;相同。</p>
<!-- description:end -->
## 解法

View File

@ -35,7 +35,7 @@ tags:
<pre>
<strong>输入:</strong>routes = [[1,2,7],[3,6,7]], source = 1, target = 6
<strong>输出:</strong>2
<strong>解释:</strong>最优策略是先乘坐第一辆公交车到达车站 7 , 然后换乘第二辆公交车到车站 6 。
<strong>解释:</strong>最优策略是先乘坐第一辆公交车到达车站 7 , 然后换乘第二辆公交车到车站 6 。
</pre>
<p><strong>示例 2</strong></p>
@ -367,55 +367,56 @@ function numBusesToDestination(routes: number[][], source: number, target: numbe
public class Solution {
public int NumBusesToDestination(int[][] routes, int source, int target) {
if (source == target) {
return 0;
return 0; // 如果起点和终点相同,直接返回 0
}
Dictionary<int, HashSet<int>> stopToRoutes = new Dictionary<int, HashSet<int>>();
List<HashSet<int>> routeToStops = new List<HashSet<int>>();
// 使用 Dictionary 构建站点到公交线路的映射
var g = new Dictionary<int, List<int>>();
for (int i = 0; i < routes.Length; i++) {
routeToStops.Add(new HashSet<int>());
foreach (int stop in routes[i]) {
routeToStops[i].Add(stop);
if (!stopToRoutes.ContainsKey(stop)) {
stopToRoutes[stop] = new HashSet<int>();
if (!g.ContainsKey(stop)) {
g[stop] = new List<int>();
}
stopToRoutes[stop].Add(i);
g[stop].Add(i); // 将公交线路编号添加到该站点的列表中
}
}
Queue<int> queue = new Queue<int>();
HashSet<int> visited = new HashSet<int>();
int ans = 0;
foreach (int routeId in stopToRoutes[source]) {
queue.Enqueue(routeId);
visited.Add(routeId);
// 如果 source 或 target 不在站点映射中,返回 -1
if (!g.ContainsKey(source) || !g.ContainsKey(target)) {
return -1;
}
while (queue.Count > 0) {
int count = queue.Count;
ans++;
// 初始化队列和访问集合
var q = new Queue<int[]>();
var visBus = new HashSet<int>(); // 记录访问过的公交线路
var visStop = new HashSet<int>(); // 记录访问过的站点
q.Enqueue(new int[] { source, 0 }); // 将起点加入队列,公交次数初始化为 0
visStop.Add(source); // 将起点标记为已访问
for (int i = 0; i < count; i++) {
int routeId = queue.Dequeue();
// 开始广度优先搜索
while (q.Count > 0) {
var current = q.Dequeue(); // 从队列中取出当前站点
int stop = current[0], busCount = current[1];
foreach (int stop in routeToStops[routeId]) {
if (stop == target) {
return ans;
}
// 如果当前站点是目标站点,返回所需的公交次数
if (stop == target) {
return busCount;
}
foreach (int nextRoute in stopToRoutes[stop]) {
if (!visited.Contains(nextRoute)) {
visited.Add(nextRoute);
queue.Enqueue(nextRoute);
// 遍历经过当前站点的所有公交线路
foreach (int bus in g[stop]) {
if (visBus.Add(bus)) { // 如果公交线路没有被访问过
// 遍历该线路上的所有站点
foreach (int nextStop in routes[bus]) {
if (visStop.Add(nextStop)) { // 如果该站点没有被访问过
q.Enqueue(new int[] { nextStop, busCount + 1 }); // 将新站点加入队列,公交次数加 1
}
}
}
}
}
return -1;
return -1; // 如果无法到达目标站点,返回 -1
}
}
```

View File

@ -327,7 +327,8 @@ public class Solution {
return 0;
}
Dictionary<int, List<int>> g = new Dictionary<int, List<int>>();
// Use Dictionary to map stops to bus routes
var g = new Dictionary<int, List<int>>();
for (int i = 0; i < routes.Length; i++) {
foreach (int stop in routes[i]) {
if (!g.ContainsKey(stop)) {
@ -337,36 +338,42 @@ public class Solution {
}
}
// If source or target is not in the mapping, return -1
if (!g.ContainsKey(source) || !g.ContainsKey(target)) {
return -1;
}
Queue<int[]> q = new Queue<int[]>();
HashSet<int> visBus = new HashSet<int>();
HashSet<int> visStop = new HashSet<int>();
q.Enqueue(new int[]{source, 0});
// Initialize queue and visited sets
var q = new Queue<int[]>();
var visBus = new HashSet<int>();
var visStop = new HashSet<int>();
q.Enqueue(new int[] { source, 0 });
visStop.Add(source);
// Begin BFS
while (q.Count > 0) {
int[] current = q.Dequeue();
var current = q.Dequeue();
int stop = current[0], busCount = current[1];
// If the current stop is the target stop, return the bus count
if (stop == target) {
return busCount;
}
// Traverse all bus routes passing through the current stop
foreach (int bus in g[stop]) {
if (!visBus.Contains(bus)) {
if (visBus.Add(bus)) {
// Traverse all stops on this bus route
foreach (int nextStop in routes[bus]) {
if (!visStop.Contains(nextStop)) {
visBus.Add(bus);
visStop.Add(nextStop);
q.Enqueue(new int[]{nextStop, busCount + 1});
if (visStop.Add(nextStop)) {
q.Enqueue(new int[] { nextStop, busCount + 1 });
}
}
}
}
}
return -1;
return -1; // If unable to reach the target stop, return -1
}
}
```

View File

@ -4,7 +4,8 @@ public class Solution {
return 0;
}
Dictionary<int, List<int>> g = new Dictionary<int, List<int>>();
// Use Dictionary to map stops to bus routes
var g = new Dictionary<int, List<int>>();
for (int i = 0; i < routes.Length; i++) {
foreach (int stop in routes[i]) {
if (!g.ContainsKey(stop)) {
@ -14,35 +15,41 @@ public class Solution {
}
}
// If source or target is not in the mapping, return -1
if (!g.ContainsKey(source) || !g.ContainsKey(target)) {
return -1;
}
Queue<int[]> q = new Queue<int[]>();
HashSet<int> visBus = new HashSet<int>();
HashSet<int> visStop = new HashSet<int>();
q.Enqueue(new int[]{source, 0});
// Initialize queue and visited sets
var q = new Queue<int[]>();
var visBus = new HashSet<int>();
var visStop = new HashSet<int>();
q.Enqueue(new int[] { source, 0 });
visStop.Add(source);
// Begin BFS
while (q.Count > 0) {
int[] current = q.Dequeue();
var current = q.Dequeue();
int stop = current[0], busCount = current[1];
// If the current stop is the target stop, return the bus count
if (stop == target) {
return busCount;
}
// Traverse all bus routes passing through the current stop
foreach (int bus in g[stop]) {
if (!visBus.Contains(bus)) {
if (visBus.Add(bus)) {
// Traverse all stops on this bus route
foreach (int nextStop in routes[bus]) {
if (!visStop.Contains(nextStop)) {
visBus.Add(bus);
visStop.Add(nextStop);
q.Enqueue(new int[]{nextStop, busCount + 1});
if (visStop.Add(nextStop)) {
q.Enqueue(new int[] { nextStop, busCount + 1 });
}
}
}
}
}
return -1;
return -1; // If unable to reach the target stop, return -1
}
}

View File

@ -59,6 +59,10 @@ tags:
<li><code>0 &lt;= start, goal &lt;= 10<sup>9</sup></code></li>
</ul>
<p>&nbsp;</p>
<p><strong>注意:</strong>本题与&nbsp;<a href="https://leetcode.cn/problems/hamming-distance/">461. 汉明距离</a>&nbsp;相同。</p>
<!-- description:end -->
## 解法

View File

@ -10,6 +10,7 @@ tags:
- 二分查找
- 前缀和
- 滑动窗口
- 单调队列
- 堆(优先队列)
---

View File

@ -10,6 +10,7 @@ tags:
- Binary Search
- Prefix Sum
- Sliding Window
- Monotonic Queue
- Heap (Priority Queue)
---

View File

@ -52,7 +52,7 @@ tags:
<strong>输入:</strong>nums = [1,2,3,4]
<strong>输出:</strong>1
<strong>解释:</strong>
子数组按位与运算的最大值是 4 。
子数组按位与运算的最大值是 4 。
能得到此结果的最长子数组是 [4],所以返回 1 。
</pre>

View File

@ -3,6 +3,7 @@ comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/2800-2899/2868.The%20Wording%20Game/README.md
tags:
- 贪心
- 数组
- 数学
- 双指针

View File

@ -3,6 +3,7 @@ comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/2800-2899/2868.The%20Wording%20Game/README_EN.md
tags:
- Greedy
- Array
- Math
- Two Pointers

View File

@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3000-3099/3088.Ma
tags:
- 贪心
- 字符串
- 计数排序
- 排序
---

View File

@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3000-3099/3088.Ma
tags:
- Greedy
- String
- Counting Sort
- Sorting
---

View File

@ -2,6 +2,10 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3284.Sum%20of%20Consecutive%20Subarrays/README.md
tags:
- 数组
- 双指针
- 动态规划
---
<!-- problem:start -->

View File

@ -2,6 +2,10 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3284.Sum%20of%20Consecutive%20Subarrays/README_EN.md
tags:
- Array
- Two Pointers
- Dynamic Programming
---
<!-- problem:start -->

View File

@ -2,6 +2,8 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3285.Find%20Indices%20of%20Stable%20Mountains/README.md
tags:
- 数组
---
<!-- problem:start -->

View File

@ -2,6 +2,8 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3285.Find%20Indices%20of%20Stable%20Mountains/README_EN.md
tags:
- Array
---
<!-- problem:start -->

View File

@ -2,6 +2,13 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3286.Find%20a%20Safe%20Walk%20Through%20a%20Grid/README.md
tags:
- 广度优先搜索
- 图
- 数组
- 矩阵
- 最短路
- 堆(优先队列)
---
<!-- problem:start -->

View File

@ -2,6 +2,13 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3286.Find%20a%20Safe%20Walk%20Through%20a%20Grid/README_EN.md
tags:
- Breadth-First Search
- Graph
- Array
- Matrix
- Shortest Path
- Heap (Priority Queue)
---
<!-- problem:start -->

View File

@ -2,6 +2,10 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3287.Find%20the%20Maximum%20Sequence%20Value%20of%20Array/README.md
tags:
- 位运算
- 数组
- 动态规划
---
<!-- problem:start -->

View File

@ -2,6 +2,10 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3287.Find%20the%20Maximum%20Sequence%20Value%20of%20Array/README_EN.md
tags:
- Bit Manipulation
- Array
- Dynamic Programming
---
<!-- problem:start -->

View File

@ -2,6 +2,10 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3288.Length%20of%20the%20Longest%20Increasing%20Path/README.md
tags:
- 数组
- 二分查找
- 排序
---
<!-- problem:start -->

View File

@ -2,6 +2,10 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3288.Length%20of%20the%20Longest%20Increasing%20Path/README_EN.md
tags:
- Array
- Binary Search
- Sorting
---
<!-- problem:start -->

View File

@ -2,6 +2,10 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3289.The%20Two%20Sneaky%20Numbers%20of%20Digitville/README.md
tags:
- 数组
- 哈希表
- 数学
---
<!-- problem:start -->

View File

@ -2,6 +2,10 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3289.The%20Two%20Sneaky%20Numbers%20of%20Digitville/README_EN.md
tags:
- Array
- Hash Table
- Math
---
<!-- problem:start -->

View File

@ -2,6 +2,9 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3290.Maximum%20Multiplication%20Score/README.md
tags:
- 数组
- 动态规划
---
<!-- problem:start -->

View File

@ -2,6 +2,9 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3290.Maximum%20Multiplication%20Score/README_EN.md
tags:
- Array
- Dynamic Programming
---
<!-- problem:start -->

View File

@ -2,6 +2,16 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3291.Minimum%20Number%20of%20Valid%20Strings%20to%20Form%20Target%20I/README.md
tags:
- 字典树
- 线段树
- 数组
- 字符串
- 二分查找
- 动态规划
- 字符串匹配
- 哈希函数
- 滚动哈希
---
<!-- problem:start -->

View File

@ -2,6 +2,16 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3291.Minimum%20Number%20of%20Valid%20Strings%20to%20Form%20Target%20I/README_EN.md
tags:
- Trie
- Segment Tree
- Array
- String
- Binary Search
- Dynamic Programming
- String Matching
- Hash Function
- Rolling Hash
---
<!-- problem:start -->
@ -20,8 +30,6 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3291.Mi
<p>Return the <strong>minimum</strong> number of <strong>valid</strong> strings that can be <em>concatenated</em> to form <code>target</code>. If it is <strong>not</strong> possible to form <code>target</code>, return <code>-1</code>.</p>
<p>A prefix of a string is a substring that starts from the beginning of the string and extends to any point within it.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

View File

@ -2,6 +2,15 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3292.Minimum%20Number%20of%20Valid%20Strings%20to%20Form%20Target%20II/README.md
tags:
- 线段树
- 数组
- 字符串
- 二分查找
- 动态规划
- 字符串匹配
- 哈希函数
- 滚动哈希
---
<!-- problem:start -->

View File

@ -2,6 +2,15 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3292.Minimum%20Number%20of%20Valid%20Strings%20to%20Form%20Target%20II/README_EN.md
tags:
- Segment Tree
- Array
- String
- Binary Search
- Dynamic Programming
- String Matching
- Hash Function
- Rolling Hash
---
<!-- problem:start -->
@ -20,8 +29,6 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3292.Mi
<p>Return the <strong>minimum</strong> number of <strong>valid</strong> strings that can be <em>concatenated</em> to form <code>target</code>. If it is <strong>not</strong> possible to form <code>target</code>, return <code>-1</code>.</p>
<p>A prefix of a string is a substring that starts from the beginning of the string and extends to any point within it.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

View File

@ -0,0 +1,160 @@
---
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README.md
tags:
- 数据库
---
<!-- problem:start -->
# [3293. Calculate Product Final Price 🔒](https://leetcode.cn/problems/calculate-product-final-price)
[English Version](/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README_EN.md)
## 题目描述
<!-- description:start -->
<p>Table: <font face="monospace"><code>Products</code></font></p>
<pre>
+------------+---------+
| Column Name| Type |
+------------+---------+
| product_id | int |
| category | varchar |
| price | decimal |
+------------+---------+
product_id is the unique key for this table.
Each row includes the product&#39;s ID, its category, and its price.
</pre>
<p>Table: <font face="monospace"><code>Discounts</code></font></p>
<pre>
+------------+---------+
| Column Name| Type |
+------------+---------+
| 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).
</pre>
<p>Write a solution to find the <strong>final price</strong> of each product after applying the <strong>category discount</strong>. If a product&#39;s category has <strong>no</strong> <strong>associated</strong> <strong>discount</strong>, its price remains <strong>unchanged</strong>.</p>
<p>Return <em>the result table ordered by</em> <code>product_id</code><em> in <strong>ascending</strong> order.</em></p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<p><strong class="example">Example:</strong></p>
<div class="example-block">
<p><strong>Input:</strong></p>
<p><code>Products</code> table:</p>
<pre class="example-io">
+------------+-------------+-------+
| product_id | category | price |
+------------+-------------+-------+
| 1 | Electronics | 1000 |
| 2 | Clothing | 50 |
| 3 | Electronics | 1200 |
| 4 | Home | 500 |
+------------+-------------+-------+
</pre>
<p><code>Discounts</code> table:</p>
<pre class="example-io">
+------------+----------+
| category | discount |
+------------+----------+
| Electronics| 10 |
| Clothing | 20 |
+------------+----------+
</pre>
<p><strong>Output:</strong></p>
<pre class="example-io">
+------------+------------+-------------+
| product_id | final_price| category |
+------------+------------+-------------+
| 1 | 900 | Electronics |
| 2 | 40 | Clothing |
| 3 | 1080 | Electronics |
| 4 | 500 | Home |
+------------+------------+-------------+
</pre>
<p><strong>Explanation:</strong></p>
<ul>
<li>For product 1, it belongs to the Electronics&nbsp;category which has a 10% discount, so the final price is 1000 - (10% of 1000) = 900.</li>
<li>For product 2, it belongs to the Clothing&nbsp;category which has a 20% discount, so the final price is 50 - (20% of 50) = 40.</li>
<li>For product 3, it belongs to the Electronics&nbsp;category and receives a 10% discount, so the final price is 1200 - (10% of 1200) = 1080.</li>
<li>For product 4, no discount is available for the Home&nbsp;category, so the final price remains 500.</li>
</ul>
Result table is ordered by product_id in ascending order.</div>
<!-- description:end -->
## 解法
<!-- solution:start -->
### 方法一:左连接
我们可以将 `Products` 表和 `Discounts` 表按照 `category` 列进行左连接,然后计算最终价格。如果某个产品的类别没有关联的折扣,那么它的价格保持不变。
<!-- tabs:start -->
#### MySQL
```sql
# Write your MySQL query statement below
SELECT
product_id,
price * (100 - IFNULL(discount, 0)) / 100 final_price,
category
FROM
Products
LEFT JOIN Discounts USING (category)
ORDER BY 1;
```
#### Pandas
```python
import pandas as pd
def calculate_final_prices(
products: pd.DataFrame, discounts: pd.DataFrame
) -> pd.DataFrame:
# Perform a left join on the 'category' column
merged_df = pd.merge(products, discounts, on="category", how="left")
# Calculate the final price
merged_df["final_price"] = (
merged_df["price"] * (100 - merged_df["discount"].fillna(0)) / 100
)
# Select the necessary columns and sort by 'product_id'
result_df = merged_df[["product_id", "final_price", "category"]].sort_values(
"product_id"
)
return result_df
```
<!-- tabs:end -->
<!-- solution:end -->
<!-- problem:end -->

View File

@ -0,0 +1,160 @@
---
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README_EN.md
tags:
- Database
---
<!-- problem:start -->
# [3293. Calculate Product Final Price 🔒](https://leetcode.com/problems/calculate-product-final-price)
[中文文档](/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README.md)
## Description
<!-- description:start -->
<p>Table: <font face="monospace"><code>Products</code></font></p>
<pre>
+------------+---------+
| Column Name| Type |
+------------+---------+
| product_id | int |
| category | varchar |
| price | decimal |
+------------+---------+
product_id is the unique key for this table.
Each row includes the product&#39;s ID, its category, and its price.
</pre>
<p>Table: <font face="monospace"><code>Discounts</code></font></p>
<pre>
+------------+---------+
| Column Name| Type |
+------------+---------+
| 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).
</pre>
<p>Write a solution to find the <strong>final price</strong> of each product after applying the <strong>category discount</strong>. If a product&#39;s category has <strong>no</strong> <strong>associated</strong> <strong>discount</strong>, its price remains <strong>unchanged</strong>.</p>
<p>Return <em>the result table ordered by</em> <code>product_id</code><em> in <strong>ascending</strong> order.</em></p>
<p>The result format is in the following example.</p>
<p>&nbsp;</p>
<p><strong class="example">Example:</strong></p>
<div class="example-block">
<p><strong>Input:</strong></p>
<p><code>Products</code> table:</p>
<pre class="example-io">
+------------+-------------+-------+
| product_id | category | price |
+------------+-------------+-------+
| 1 | Electronics | 1000 |
| 2 | Clothing | 50 |
| 3 | Electronics | 1200 |
| 4 | Home | 500 |
+------------+-------------+-------+
</pre>
<p><code>Discounts</code> table:</p>
<pre class="example-io">
+------------+----------+
| category | discount |
+------------+----------+
| Electronics| 10 |
| Clothing | 20 |
+------------+----------+
</pre>
<p><strong>Output:</strong></p>
<pre class="example-io">
+------------+------------+-------------+
| product_id | final_price| category |
+------------+------------+-------------+
| 1 | 900 | Electronics |
| 2 | 40 | Clothing |
| 3 | 1080 | Electronics |
| 4 | 500 | Home |
+------------+------------+-------------+
</pre>
<p><strong>Explanation:</strong></p>
<ul>
<li>For product 1, it belongs to the Electronics&nbsp;category which has a 10% discount, so the final price is 1000 - (10% of 1000) = 900.</li>
<li>For product 2, it belongs to the Clothing&nbsp;category which has a 20% discount, so the final price is 50 - (20% of 50) = 40.</li>
<li>For product 3, it belongs to the Electronics&nbsp;category and receives a 10% discount, so the final price is 1200 - (10% of 1200) = 1080.</li>
<li>For product 4, no discount is available for the Home&nbsp;category, so the final price remains 500.</li>
</ul>
Result table is ordered by product_id in ascending order.</div>
<!-- description:end -->
## Solutions
<!-- solution:start -->
### Solution 1: Left Join
We can perform a left join between the `Products` table and the `Discounts` table on the `category` column, then calculate the final price. If a product's category does not have an associated discount, its price remains unchanged.
<!-- tabs:start -->
#### MySQL
```sql
# Write your MySQL query statement below
SELECT
product_id,
price * (100 - IFNULL(discount, 0)) / 100 final_price,
category
FROM
Products
LEFT JOIN Discounts USING (category)
ORDER BY 1;
```
#### Pandas
```python
import pandas as pd
def calculate_final_prices(
products: pd.DataFrame, discounts: pd.DataFrame
) -> pd.DataFrame:
# Perform a left join on the 'category' column
merged_df = pd.merge(products, discounts, on="category", how="left")
# Calculate the final price
merged_df["final_price"] = (
merged_df["price"] * (100 - merged_df["discount"].fillna(0)) / 100
)
# Select the necessary columns and sort by 'product_id'
result_df = merged_df[["product_id", "final_price", "category"]].sort_values(
"product_id"
)
return result_df
```
<!-- tabs:end -->
<!-- solution:end -->
<!-- problem:end -->

View File

@ -0,0 +1,20 @@
import pandas as pd
def calculate_final_prices(
products: pd.DataFrame, discounts: pd.DataFrame
) -> pd.DataFrame:
# Perform a left join on the 'category' column
merged_df = pd.merge(products, discounts, on="category", how="left")
# Calculate the final price
merged_df["final_price"] = (
merged_df["price"] * (100 - merged_df["discount"].fillna(0)) / 100
)
# Select the necessary columns and sort by 'product_id'
result_df = merged_df[["product_id", "final_price", "category"]].sort_values(
"product_id"
)
return result_df

View File

@ -0,0 +1,9 @@
# Write your MySQL query statement below
SELECT
product_id,
price * (100 - IFNULL(discount, 0)) / 100 final_price,
category
FROM
Products
LEFT JOIN Discounts USING (category)
ORDER BY 1;

View File

@ -295,6 +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) | `数据库` | 中等 | 🔒 |
## 版权

View File

@ -293,6 +293,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
| 3262 | [Find Overlapping Shifts](/solution/3200-3299/3262.Find%20Overlapping%20Shifts/README_EN.md) | `Database` | Medium | 🔒 |
| 3268 | [Find Overlapping Shifts II](/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README_EN.md) | `Database` | Hard | 🔒 |
| 3278 | [Find Candidates for Data Scientist Position II](/solution/3200-3299/3278.Find%20Candidates%20for%20Data%20Scientist%20Position%20II/README_EN.md) | `Database` | Medium | 🔒 |
| 3293 | [Calculate Product Final Price](/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README_EN.md) | `Database` | Medium | 🔒 |
## Copyright

View File

@ -2408,7 +2408,7 @@
| 2395 | [和相等的子数组](/solution/2300-2399/2395.Find%20Subarrays%20With%20Equal%20Sum/README.md) | `数组`,`哈希表` | 简单 | 第 86 场双周赛 |
| 2396 | [严格回文的数字](/solution/2300-2399/2396.Strictly%20Palindromic%20Number/README.md) | `脑筋急转弯`,`数学`,`双指针` | 中等 | 第 86 场双周赛 |
| 2397 | [被列覆盖的最多行数](/solution/2300-2399/2397.Maximum%20Rows%20Covered%20by%20Columns/README.md) | `位运算`,`数组`,`回溯`,`枚举`,`矩阵` | 中等 | 第 86 场双周赛 |
| 2398 | [预算内的最多机器人数目](/solution/2300-2399/2398.Maximum%20Number%20of%20Robots%20Within%20Budget/README.md) | `队列`,`数组`,`二分查找`,`前缀和`,`滑动窗口`,`堆(优先队列)` | 困难 | 第 86 场双周赛 |
| 2398 | [预算内的最多机器人数目](/solution/2300-2399/2398.Maximum%20Number%20of%20Robots%20Within%20Budget/README.md) | `队列`,`数组`,`二分查找`,`前缀和`,`滑动窗口`,`单调队列`,`堆(优先队列)` | 困难 | 第 86 场双周赛 |
| 2399 | [检查相同字母间的距离](/solution/2300-2399/2399.Check%20Distances%20Between%20Same%20Letters/README.md) | `数组`,`哈希表`,`字符串` | 简单 | 第 309 场周赛 |
| 2400 | [恰好移动 k 步到达某一位置的方法数目](/solution/2400-2499/2400.Number%20of%20Ways%20to%20Reach%20a%20Position%20After%20Exactly%20k%20Steps/README.md) | `数学`,`动态规划`,`组合数学` | 中等 | 第 309 场周赛 |
| 2401 | [最长优雅子数组](/solution/2400-2499/2401.Longest%20Nice%20Subarray/README.md) | `位运算`,`数组`,`滑动窗口` | 中等 | 第 309 场周赛 |
@ -2878,7 +2878,7 @@
| 2865 | [美丽塔 I](/solution/2800-2899/2865.Beautiful%20Towers%20I/README.md) | `栈`,`数组`,`单调栈` | 中等 | 第 364 场周赛 |
| 2866 | [美丽塔 II](/solution/2800-2899/2866.Beautiful%20Towers%20II/README.md) | `栈`,`数组`,`单调栈` | 中等 | 第 364 场周赛 |
| 2867 | [统计树中的合法路径数目](/solution/2800-2899/2867.Count%20Valid%20Paths%20in%20a%20Tree/README.md) | `树`,`深度优先搜索`,`数学`,`动态规划`,`数论` | 困难 | 第 364 场周赛 |
| 2868 | [单词游戏](/solution/2800-2899/2868.The%20Wording%20Game/README.md) | `数组`,`数学`,`双指针`,`字符串`,`博弈` | 困难 | 🔒 |
| 2868 | [单词游戏](/solution/2800-2899/2868.The%20Wording%20Game/README.md) | `贪心`,`数组`,`数学`,`双指针`,`字符串`,`博弈` | 困难 | 🔒 |
| 2869 | [收集元素的最少操作次数](/solution/2800-2899/2869.Minimum%20Operations%20to%20Collect%20Elements/README.md) | `位运算`,`数组`,`哈希表` | 简单 | 第 114 场双周赛 |
| 2870 | [使数组为空的最少操作次数](/solution/2800-2899/2870.Minimum%20Number%20of%20Operations%20to%20Make%20Array%20Empty/README.md) | `贪心`,`数组`,`哈希表`,`计数` | 中等 | 第 114 场双周赛 |
| 2871 | [将数组分割成最多数目的子数组](/solution/2800-2899/2871.Split%20Array%20Into%20Maximum%20Number%20of%20Subarrays/README.md) | `贪心`,`位运算`,`数组` | 中等 | 第 114 场双周赛 |
@ -3098,7 +3098,7 @@
| 3085 | [成为 K 特殊字符串需要删除的最少字符数](/solution/3000-3099/3085.Minimum%20Deletions%20to%20Make%20String%20K-Special/README.md) | `贪心`,`哈希表`,`字符串`,`计数`,`排序` | 中等 | 第 389 场周赛 |
| 3086 | [拾起 K 个 1 需要的最少行动次数](/solution/3000-3099/3086.Minimum%20Moves%20to%20Pick%20K%20Ones/README.md) | `贪心`,`数组`,`前缀和`,`滑动窗口` | 困难 | 第 389 场周赛 |
| 3087 | [查找热门话题标签](/solution/3000-3099/3087.Find%20Trending%20Hashtags/README.md) | `数据库` | 中等 | 🔒 |
| 3088 | [使字符串反回文](/solution/3000-3099/3088.Make%20String%20Anti-palindrome/README.md) | `贪心`,`字符串`,`排序` | 困难 | 🔒 |
| 3088 | [使字符串反回文](/solution/3000-3099/3088.Make%20String%20Anti-palindrome/README.md) | `贪心`,`字符串`,`计数排序`,`排序` | 困难 | 🔒 |
| 3089 | [查找突发行为](/solution/3000-3099/3089.Find%20Bursty%20Behavior/README.md) | `数据库` | 中等 | 🔒 |
| 3090 | [每个字符最多出现两次的最长子字符串](/solution/3000-3099/3090.Maximum%20Length%20Substring%20With%20Two%20Occurrences/README.md) | `哈希表`,`字符串`,`滑动窗口` | 简单 | 第 390 场周赛 |
| 3091 | [执行操作使数据元素之和大于等于 K](/solution/3000-3099/3091.Apply%20Operations%20to%20Make%20Sum%20of%20Array%20Greater%20Than%20or%20Equal%20to%20k/README.md) | `贪心`,`数学`,`枚举` | 中等 | 第 390 场周赛 |
@ -3294,15 +3294,16 @@
| 3281 | [范围内整数的最大得分](/solution/3200-3299/3281.Maximize%20Score%20of%20Numbers%20in%20Ranges/README.md) | `贪心`,`数组`,`二分查找`,`排序` | 中等 | 第 414 场周赛 |
| 3282 | [到达数组末尾的最大得分](/solution/3200-3299/3282.Reach%20End%20of%20Array%20With%20Max%20Score/README.md) | `贪心`,`数组` | 中等 | 第 414 场周赛 |
| 3283 | [吃掉所有兵需要的最多移动次数](/solution/3200-3299/3283.Maximum%20Number%20of%20Moves%20to%20Kill%20All%20Pawns/README.md) | `位运算`,`广度优先搜索`,`数组`,`数学`,`状态压缩`,`博弈` | 困难 | 第 414 场周赛 |
| 3284 | [Sum of Consecutive Subarrays](/solution/3200-3299/3284.Sum%20of%20Consecutive%20Subarrays/README.md) | | 中等 | 🔒 |
| 3285 | [找到稳定山的下标](/solution/3200-3299/3285.Find%20Indices%20of%20Stable%20Mountains/README.md) | | 简单 | 第 139 场双周赛 |
| 3286 | [穿越网格图的安全路径](/solution/3200-3299/3286.Find%20a%20Safe%20Walk%20Through%20a%20Grid/README.md) | | 中等 | 第 139 场双周赛 |
| 3287 | [求出数组中最大序列值](/solution/3200-3299/3287.Find%20the%20Maximum%20Sequence%20Value%20of%20Array/README.md) | | 困难 | 第 139 场双周赛 |
| 3288 | [最长上升路径的长度](/solution/3200-3299/3288.Length%20of%20the%20Longest%20Increasing%20Path/README.md) | | 困难 | 第 139 场双周赛 |
| 3289 | [数字小镇中的捣蛋鬼](/solution/3200-3299/3289.The%20Two%20Sneaky%20Numbers%20of%20Digitville/README.md) | | 简单 | 第 415 场周赛 |
| 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 场周赛 |
| 3284 | [Sum of Consecutive Subarrays](/solution/3200-3299/3284.Sum%20of%20Consecutive%20Subarrays/README.md) | `数组`,`双指针`,`动态规划` | 中等 | 🔒 |
| 3285 | [找到稳定山的下标](/solution/3200-3299/3285.Find%20Indices%20of%20Stable%20Mountains/README.md) | `数组` | 简单 | 第 139 场双周赛 |
| 3286 | [穿越网格图的安全路径](/solution/3200-3299/3286.Find%20a%20Safe%20Walk%20Through%20a%20Grid/README.md) | `广度优先搜索`,`图`,`数组`,`矩阵`,`最短路`,`堆(优先队列)` | 中等 | 第 139 场双周赛 |
| 3287 | [求出数组中最大序列值](/solution/3200-3299/3287.Find%20the%20Maximum%20Sequence%20Value%20of%20Array/README.md) | `位运算`,`数组`,`动态规划` | 困难 | 第 139 场双周赛 |
| 3288 | [最长上升路径的长度](/solution/3200-3299/3288.Length%20of%20the%20Longest%20Increasing%20Path/README.md) | `数组`,`二分查找`,`排序` | 困难 | 第 139 场双周赛 |
| 3289 | [数字小镇中的捣蛋鬼](/solution/3200-3299/3289.The%20Two%20Sneaky%20Numbers%20of%20Digitville/README.md) | `数组`,`哈希表`,`数学` | 简单 | 第 415 场周赛 |
| 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) | `数据库` | 中等 | 🔒 |
## 版权

View File

@ -2406,7 +2406,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
| 2395 | [Find Subarrays With Equal Sum](/solution/2300-2399/2395.Find%20Subarrays%20With%20Equal%20Sum/README_EN.md) | `Array`,`Hash Table` | Easy | Biweekly Contest 86 |
| 2396 | [Strictly Palindromic Number](/solution/2300-2399/2396.Strictly%20Palindromic%20Number/README_EN.md) | `Brainteaser`,`Math`,`Two Pointers` | Medium | Biweekly Contest 86 |
| 2397 | [Maximum Rows Covered by Columns](/solution/2300-2399/2397.Maximum%20Rows%20Covered%20by%20Columns/README_EN.md) | `Bit Manipulation`,`Array`,`Backtracking`,`Enumeration`,`Matrix` | Medium | Biweekly Contest 86 |
| 2398 | [Maximum Number of Robots Within Budget](/solution/2300-2399/2398.Maximum%20Number%20of%20Robots%20Within%20Budget/README_EN.md) | `Queue`,`Array`,`Binary Search`,`Prefix Sum`,`Sliding Window`,`Heap (Priority Queue)` | Hard | Biweekly Contest 86 |
| 2398 | [Maximum Number of Robots Within Budget](/solution/2300-2399/2398.Maximum%20Number%20of%20Robots%20Within%20Budget/README_EN.md) | `Queue`,`Array`,`Binary Search`,`Prefix Sum`,`Sliding Window`,`Monotonic Queue`,`Heap (Priority Queue)` | Hard | Biweekly Contest 86 |
| 2399 | [Check Distances Between Same Letters](/solution/2300-2399/2399.Check%20Distances%20Between%20Same%20Letters/README_EN.md) | `Array`,`Hash Table`,`String` | Easy | Weekly Contest 309 |
| 2400 | [Number of Ways to Reach a Position After Exactly k Steps](/solution/2400-2499/2400.Number%20of%20Ways%20to%20Reach%20a%20Position%20After%20Exactly%20k%20Steps/README_EN.md) | `Math`,`Dynamic Programming`,`Combinatorics` | Medium | Weekly Contest 309 |
| 2401 | [Longest Nice Subarray](/solution/2400-2499/2401.Longest%20Nice%20Subarray/README_EN.md) | `Bit Manipulation`,`Array`,`Sliding Window` | Medium | Weekly Contest 309 |
@ -2876,7 +2876,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
| 2865 | [Beautiful Towers I](/solution/2800-2899/2865.Beautiful%20Towers%20I/README_EN.md) | `Stack`,`Array`,`Monotonic Stack` | Medium | Weekly Contest 364 |
| 2866 | [Beautiful Towers II](/solution/2800-2899/2866.Beautiful%20Towers%20II/README_EN.md) | `Stack`,`Array`,`Monotonic Stack` | Medium | Weekly Contest 364 |
| 2867 | [Count Valid Paths in a Tree](/solution/2800-2899/2867.Count%20Valid%20Paths%20in%20a%20Tree/README_EN.md) | `Tree`,`Depth-First Search`,`Math`,`Dynamic Programming`,`Number Theory` | Hard | Weekly Contest 364 |
| 2868 | [The Wording Game](/solution/2800-2899/2868.The%20Wording%20Game/README_EN.md) | `Array`,`Math`,`Two Pointers`,`String`,`Game Theory` | Hard | 🔒 |
| 2868 | [The Wording Game](/solution/2800-2899/2868.The%20Wording%20Game/README_EN.md) | `Greedy`,`Array`,`Math`,`Two Pointers`,`String`,`Game Theory` | Hard | 🔒 |
| 2869 | [Minimum Operations to Collect Elements](/solution/2800-2899/2869.Minimum%20Operations%20to%20Collect%20Elements/README_EN.md) | `Bit Manipulation`,`Array`,`Hash Table` | Easy | Biweekly Contest 114 |
| 2870 | [Minimum Number of Operations to Make Array Empty](/solution/2800-2899/2870.Minimum%20Number%20of%20Operations%20to%20Make%20Array%20Empty/README_EN.md) | `Greedy`,`Array`,`Hash Table`,`Counting` | Medium | Biweekly Contest 114 |
| 2871 | [Split Array Into Maximum Number of Subarrays](/solution/2800-2899/2871.Split%20Array%20Into%20Maximum%20Number%20of%20Subarrays/README_EN.md) | `Greedy`,`Bit Manipulation`,`Array` | Medium | Biweekly Contest 114 |
@ -3096,7 +3096,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
| 3085 | [Minimum Deletions to Make String K-Special](/solution/3000-3099/3085.Minimum%20Deletions%20to%20Make%20String%20K-Special/README_EN.md) | `Greedy`,`Hash Table`,`String`,`Counting`,`Sorting` | Medium | Weekly Contest 389 |
| 3086 | [Minimum Moves to Pick K Ones](/solution/3000-3099/3086.Minimum%20Moves%20to%20Pick%20K%20Ones/README_EN.md) | `Greedy`,`Array`,`Prefix Sum`,`Sliding Window` | Hard | Weekly Contest 389 |
| 3087 | [Find Trending Hashtags](/solution/3000-3099/3087.Find%20Trending%20Hashtags/README_EN.md) | `Database` | Medium | 🔒 |
| 3088 | [Make String Anti-palindrome](/solution/3000-3099/3088.Make%20String%20Anti-palindrome/README_EN.md) | `Greedy`,`String`,`Sorting` | Hard | 🔒 |
| 3088 | [Make String Anti-palindrome](/solution/3000-3099/3088.Make%20String%20Anti-palindrome/README_EN.md) | `Greedy`,`String`,`Counting Sort`,`Sorting` | Hard | 🔒 |
| 3089 | [Find Bursty Behavior](/solution/3000-3099/3089.Find%20Bursty%20Behavior/README_EN.md) | `Database` | Medium | 🔒 |
| 3090 | [Maximum Length Substring With Two Occurrences](/solution/3000-3099/3090.Maximum%20Length%20Substring%20With%20Two%20Occurrences/README_EN.md) | `Hash Table`,`String`,`Sliding Window` | Easy | Weekly Contest 390 |
| 3091 | [Apply Operations to Make Sum of Array Greater Than or Equal to k](/solution/3000-3099/3091.Apply%20Operations%20to%20Make%20Sum%20of%20Array%20Greater%20Than%20or%20Equal%20to%20k/README_EN.md) | `Greedy`,`Math`,`Enumeration` | Medium | Weekly Contest 390 |
@ -3292,15 +3292,16 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
| 3281 | [Maximize Score of Numbers in Ranges](/solution/3200-3299/3281.Maximize%20Score%20of%20Numbers%20in%20Ranges/README_EN.md) | `Greedy`,`Array`,`Binary Search`,`Sorting` | Medium | Weekly Contest 414 |
| 3282 | [Reach End of Array With Max Score](/solution/3200-3299/3282.Reach%20End%20of%20Array%20With%20Max%20Score/README_EN.md) | `Greedy`,`Array` | Medium | Weekly Contest 414 |
| 3283 | [Maximum Number of Moves to Kill All Pawns](/solution/3200-3299/3283.Maximum%20Number%20of%20Moves%20to%20Kill%20All%20Pawns/README_EN.md) | `Bit Manipulation`,`Breadth-First Search`,`Array`,`Math`,`Bitmask`,`Game Theory` | Hard | Weekly Contest 414 |
| 3284 | [Sum of Consecutive Subarrays](/solution/3200-3299/3284.Sum%20of%20Consecutive%20Subarrays/README_EN.md) | | Medium | 🔒 |
| 3285 | [Find Indices of Stable Mountains](/solution/3200-3299/3285.Find%20Indices%20of%20Stable%20Mountains/README_EN.md) | | Easy | Biweekly Contest 139 |
| 3286 | [Find a Safe Walk Through a Grid](/solution/3200-3299/3286.Find%20a%20Safe%20Walk%20Through%20a%20Grid/README_EN.md) | | Medium | Biweekly Contest 139 |
| 3287 | [Find the Maximum Sequence Value of Array](/solution/3200-3299/3287.Find%20the%20Maximum%20Sequence%20Value%20of%20Array/README_EN.md) | | Hard | Biweekly Contest 139 |
| 3288 | [Length of the Longest Increasing Path](/solution/3200-3299/3288.Length%20of%20the%20Longest%20Increasing%20Path/README_EN.md) | | Hard | Biweekly Contest 139 |
| 3289 | [The Two Sneaky Numbers of Digitville](/solution/3200-3299/3289.The%20Two%20Sneaky%20Numbers%20of%20Digitville/README_EN.md) | | Easy | Weekly Contest 415 |
| 3290 | [Maximum Multiplication Score](/solution/3200-3299/3290.Maximum%20Multiplication%20Score/README_EN.md) | | Medium | Weekly Contest 415 |
| 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) | | 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) | | Hard | Weekly Contest 415 |
| 3284 | [Sum of Consecutive Subarrays](/solution/3200-3299/3284.Sum%20of%20Consecutive%20Subarrays/README_EN.md) | `Array`,`Two Pointers`,`Dynamic Programming` | Medium | 🔒 |
| 3285 | [Find Indices of Stable Mountains](/solution/3200-3299/3285.Find%20Indices%20of%20Stable%20Mountains/README_EN.md) | `Array` | Easy | Biweekly Contest 139 |
| 3286 | [Find a Safe Walk Through a Grid](/solution/3200-3299/3286.Find%20a%20Safe%20Walk%20Through%20a%20Grid/README_EN.md) | `Breadth-First Search`,`Graph`,`Array`,`Matrix`,`Shortest Path`,`Heap (Priority Queue)` | Medium | Biweekly Contest 139 |
| 3287 | [Find the Maximum Sequence Value of Array](/solution/3200-3299/3287.Find%20the%20Maximum%20Sequence%20Value%20of%20Array/README_EN.md) | `Bit Manipulation`,`Array`,`Dynamic Programming` | Hard | Biweekly Contest 139 |
| 3288 | [Length of the Longest Increasing Path](/solution/3200-3299/3288.Length%20of%20the%20Longest%20Increasing%20Path/README_EN.md) | `Array`,`Binary Search`,`Sorting` | Hard | Biweekly Contest 139 |
| 3289 | [The Two Sneaky Numbers of Digitville](/solution/3200-3299/3289.The%20Two%20Sneaky%20Numbers%20of%20Digitville/README_EN.md) | `Array`,`Hash Table`,`Math` | Easy | Weekly Contest 415 |
| 3290 | [Maximum Multiplication Score](/solution/3200-3299/3290.Maximum%20Multiplication%20Score/README_EN.md) | `Array`,`Dynamic Programming` | Medium | Weekly Contest 415 |
| 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 | 🔒 |
## Copyright

File diff suppressed because one or more lines are too long