Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ tags:

<pre><strong>输入:</strong>target = [3,1,5,4,2]
<strong>输出:</strong>7
<strong>解释:</strong>(initial)[0,0,0,0,0] -&gt; [1,1,1,1,1] -&gt; [2,1,1,1,1] -&gt; [3,1,1,1,1]
<strong>解释:</strong>(initial)[0,0,0,0,0] -&gt; [1,1,1,1,1] -&gt; [2,1,1,1,1] -&gt; [3,1,1,1,1]
-&gt; [3,1,2,2,2] -&gt; [3,1,3,3,2] -&gt; [3,1,4,4,2] -&gt; [3,1,5,4,2] (target)。
</pre>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tags:
<strong>Explanation:</strong>
Nodes 0 and 1 are the twins of nodes 3 and 2, respectively. All have twin sum = 6.
There are no other nodes with twins in the linked list.
Thus, the maximum twin sum of the linked list is 6.
Thus, the maximum twin sum of the linked list is 6.
</pre>

<p><strong class="example">Example 2:</strong></p>
Expand All @@ -51,7 +51,7 @@ Thus, the maximum twin sum of the linked list is 6.
The nodes with twins present in this linked list are:
- Node 0 is the twin of node 3 having a twin sum of 4 + 3 = 7.
- Node 1 is the twin of node 2 having a twin sum of 2 + 2 = 4.
Thus, the maximum twin sum of the linked list is max(7, 4) = 7.
Thus, the maximum twin sum of the linked list is max(7, 4) = 7.
</pre>

<p><strong class="example">Example 3:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ tags:
<pre>
<strong>Input:</strong> stations = [1,2,4,5,0], r = 1, k = 2
<strong>Output:</strong> 5
<strong>Explanation:</strong>
One of the optimal ways is to install both the power stations at city 1.
<strong>Explanation:</strong>
One of the optimal ways is to install both the power stations at city 1.
So stations will become [1,4,4,5,0].
- City 0 is provided by 1 + 4 = 5 power stations.
- City 1 is provided by 1 + 4 + 4 = 9 power stations.
Expand All @@ -62,7 +62,7 @@ Since it is not possible to obtain a larger power, we return 5.
<pre>
<strong>Input:</strong> stations = [4,4,4,4], r = 0, k = 3
<strong>Output:</strong> 4
<strong>Explanation:</strong>
<strong>Explanation:</strong>
It can be proved that we cannot make the minimum power of a city greater than 4.
</pre>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3632.Subarrays%20with%20XOR%20at%20Least%20K/README.md
tags:
- 位运算
-
- 字典树
- 数组
- 前缀和
---

<!-- problem:start -->

# [3632. 子数组异或至少为 K 的数目 🔒](https://leetcode.cn/problems/subarrays-with-xor-at-least-k)
# [3632. 异或至少为 K 的子数组数目 🔒](https://leetcode.cn/problems/subarrays-with-xor-at-least-k)

[English Version](/solution/3600-3699/3632.Subarrays%20with%20XOR%20at%20Least%20K/README_EN.md)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3632.Subarrays%20with%20XOR%20at%20Least%20K/README_EN.md
tags:
- Bit Manipulation
- Tree
- Trie
- Array
- Prefix Sum
---
Expand Down
2 changes: 2 additions & 0 deletions solution/3600-3699/3657.Find Loyal Customers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ transaction_type 可以是 “purchase” 或 “refund”。
<li>他们的 <strong>退款率</strong>&nbsp;少于&nbsp;<code>20%</code>。</li>
</ul>

<p>退款率是退款交易占交易总数(购买加退款)的比例,计算公式为退款交易数量除以总交易数量。</p>

<p>返回结果表以&nbsp;<code>customer_id</code> <strong>升序</strong>&nbsp;排序。</p>

<p>结果格式如下所示。</p>
Expand Down
2 changes: 2 additions & 0 deletions solution/3600-3699/3657.Find Loyal Customers/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ transaction_type can be either &#39;purchase&#39; or &#39;refund&#39;.
<li>Their <strong>refund rate</strong> is less than <code>20%</code> .</li>
</ul>

<p><em>Refund rate</em> is the proportion of transactions that are refunds, calculated as the number of refund transactions divided by the total number of transactions (purchases plus refunds).</p>

<p>Return <em>the result table&nbsp;ordered by</em> <code>customer_id</code> <em>in <strong>ascending</strong> order</em>.</p>

<p>The result format is in the following example.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ rating: 2476
source: 第 164 场双周赛 Q4
tags:
- 广度优先搜索
- 哈希表
- 并查集
- 数学
- 字符串
- 有序集合
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ rating: 2476
source: Biweekly Contest 164 Q4
tags:
- Breadth-First Search
- Hash Table
- Union Find
- Math
- String
- Ordered Set
---

<!-- problem:start -->
Expand Down
3 changes: 3 additions & 0 deletions solution/3700-3799/3701.Compute Alternating Sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3701.Compute%20Alternating%20Sum/README.md
rating: 1228
source: 第 470 场周赛 Q1
tags:
- 数组
- 模拟
---

<!-- problem:start -->
Expand Down
3 changes: 3 additions & 0 deletions solution/3700-3799/3701.Compute Alternating Sum/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3701.Compute%20Alternating%20Sum/README_EN.md
rating: 1228
source: Weekly Contest 470 Q1
tags:
- Array
- Simulation
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3702.Longest%20Subsequence%20With%20Non-Zero%20Bitwise%20XOR/README.md
rating: 1489
source: 第 470 场周赛 Q2
tags:
- 位运算
- 数组
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3702.Longest%20Subsequence%20With%20Non-Zero%20Bitwise%20XOR/README_EN.md
rating: 1489
source: Weekly Contest 470 Q2
tags:
- Bit Manipulation
- Array
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3703.Remove%20K-Balanced%20Substrings/README.md
rating: 1802
source: 第 470 场周赛 Q3
tags:
- 栈
- 字符串
- 模拟
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3703.Remove%20K-Balanced%20Substrings/README_EN.md
rating: 1802
source: Weekly Contest 470 Q3
tags:
- Stack
- String
- Simulation
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3704.Count%20No-Zero%20Pairs%20That%20Sum%20to%20N/README.md
rating: 2419
source: 第 470 场周赛 Q4
tags:
- 数学
- 动态规划
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3704.Count%20No-Zero%20Pairs%20That%20Sum%20to%20N/README_EN.md
rating: 2419
source: Weekly Contest 470 Q4
tags:
- Math
- Dynamic Programming
---

<!-- problem:start -->
Expand Down
107 changes: 54 additions & 53 deletions solution/3700-3799/3705.Find Golden Hour Customers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ tags:

<!-- problem:start -->

# [3705. Find Golden Hour Customers](https://leetcode.cn/problems/find-golden-hour-customers)
# [3705. 寻找黄金时段客户](https://leetcode.cn/problems/find-golden-hour-customers)

[English Version](/solution/3700-3799/3705.Find%20Golden%20Hour%20Customers/README_EN.md)

## 题目描述

<!-- description:start -->

<p>Table: <code>restaurant_orders</code></p>
<p>表:<code>restaurant_orders</code></p>

<pre>
+------------------+----------+
Expand All @@ -29,32 +29,33 @@ tags:
| payment_method | varchar |
| order_rating | int |
+------------------+----------+
order_id is the unique identifier for this table.
payment_method can be cash, card, or app.
order_rating is between 1 and 5, where 5 is the best (NULL if not rated).
order_timestamp contains both date and time information.
order_id 是这张表的唯一主键。
payment_method 可以是 cashcard app
order_rating 在 1 到 5 之间,其中 5 是最佳(如果没有评分则是 NULL)。
order_timestamp 同时包含日期和时间信息。
</pre>

<p>Write a solution to find <strong>golden hour customers</strong>&nbsp;- customers who consistently order during peak hours and provide high satisfaction. A customer is a <strong>golden hour customer</strong> if they meet ALL the following criteria:</p>
<p>编写一个解决方案来寻找 <strong>黄金时间客户</strong>&nbsp;- 高峰时段持续订购且满意度高的客户。客户若满足以下所有条件,则被视为 <strong>黄金时段客户</strong></p>

<ul>
<li>Made <strong>at least</strong> <code>3</code> orders.</li>
<li><strong>At least</strong> <code>60%</code> of their orders are during <strong>peak hours&nbsp;</strong>(<code>11:00</code>-<code>14:00</code> or <code>18:00</code>-<code>21:00</code>).</li>
<li>Their <strong>average rating</strong> for rated orders is at least <code>4.0,</code> round it to<code> 2 </code>decimal places.</li>
<li>Have rated <strong>at least</strong> <code>50%</code> of their orders.</li>
<li>进行 <strong>至少</strong>&nbsp;<code>3</code>&nbsp;笔订单。</li>
<li>他们有&nbsp;<strong>至少</strong>&nbsp;<code>60%</code>&nbsp;的订单在 <strong>高峰时间</strong>&nbsp;中(<code>11:00</code>-<code>14:00</code> 或&nbsp;<code>18:00</code>-<code>21:00</code>)。</li>
<li>他们的 <strong>平均评分</strong> 至少为 <code>4.0</code>,四舍五入到小数点后 <code>2</code> 位。</li>
<li>已评价至少 <code>50%</code> 的订单。</li>
</ul>

<p>Return <em>the result table ordered by</em> <code>average_rating</code> <em>in <strong>descending</strong> order, then by</em> <code>customer_id</code>​​​​​​​ <em>in <strong>descending</strong> order</em>.</p>
<p>返回结果表按&nbsp;<code>average_rating</code> <strong>降序</strong>&nbsp;排序,然后按&nbsp;<code>customer_id</code> <strong>降序&nbsp;</strong>排序。</p>

<p>The result format is in the following example.</p>
<p>结果格式如下所示。</p>

<p>&nbsp;</p>
<p><strong class="example">Example:</strong></p>

<p><strong class="example">示例:</strong></p>

<div class="example-block">
<p><strong>Input:</strong></p>
<p><b>输入:</b></p>

<p>restaurant_orders table:</p>
<p>restaurant_orders 表:</p>

<pre class="example-io">
+----------+-------------+---------------------+--------------+----------------+--------------+
Expand All @@ -79,74 +80,74 @@ order_timestamp contains both date and time information.
+----------+-------------+---------------------+--------------+----------------+--------------+
</pre>

<p><strong>Output:</strong></p>
<p><strong>输出:</strong></p>

<pre class="example-io">
+-------------+--------------+----------------------+----------------+
| customer_id | total_orders | peak_hour_percentage | average_rating |
+-------------+--------------+----------------------+----------------+
| 103 | 3 | 100 | 4.67 |
| 101 | 4 | 75 | 4.67 |
| 101 | 4 | 100 | 4.67 |
| 105 | 3 | 100 | 4.33 |
+-------------+--------------+----------------------+----------------+
</pre>

<p><strong>Explanation:</strong></p>
<p><strong>解释:</strong></p>

<ul>
<li><strong>Customer 101</strong>:
<li><strong>客户 101</strong>

<ul>
<li>Total orders: 4 (at least 3)&nbsp;</li>
<li>Peak hour orders: 3 out of 4 (12:30, 19:15, 13:45, and 20:30 are in peak hours)</li>
<li>Peak hour percentage: 3/4 = 75% (at least 60%)&nbsp;</li>
<li>Rated orders: 3 out of 4 (75% rating completion)&nbsp;</li>
<li>Average rating: (5+4+5)/3 = 4.67 (at least 4.0)&nbsp;</li>
<li>Result: <strong>Golden hour customer</strong></li>
<li>总订单数:4(至少 3 笔)</li>
<li>高峰时间订单:4 笔中有 4 笔(12:3019:1513:45 20:30 在高峰时间)</li>
<li>高峰时间占比:100%(至少 60%</li>
<li>已评分的订单:4 笔中有 3 笔(75% 评分完成率)</li>
<li>平均评分:(5+4+5)/3 = 4.67(至少 4.0</li>
<li>结果:<strong>黄金时段客户</strong></li>
</ul>
</li>
<li><strong>Customer 102</strong>:
<li><strong>客户 102</strong>:
<ul>
<li>Total orders: 3 (at least 3)&nbsp;</li>
<li>Peak hour orders: 2 out of 3 (11:30, 12:00 are in peak hours; 15:30 is not)</li>
<li>Peak hour percentage: 2/3 = 66.67% (at least 60%)&nbsp;</li>
<li>Rated orders: 2 out of 3 (66.67% rating completion)&nbsp;</li>
<li>Average rating: (4+3)/2 = 3.5 (less than 4.0)&nbsp;</li>
<li>Result: <strong>Not a golden hour customer</strong> (average rating too low)</li>
<li>总订单数:3(至少 3 笔)</li>
<li>高峰时间订单:3 笔中有 2 笔(11:3012:00 都在高峰时间,但 15:30 不是)</li>
<li>高峰时间占比:2/3 = 66.67%(至少 60%</li>
<li>已评分的订单:3 笔中有 2 笔(66.67% 评分完成率)</li>
<li>平均评分:(4+3)/2 = 3.5(少于 4.0</li>
<li>结果:<strong>不是黄金时段客户</strong>(平均评分太低)</li>
</ul>
</li>
<li><strong>Customer 103</strong>:
<li><strong>客户 103</strong>:
<ul>
<li>Total orders: 3 (at least 3)&nbsp;</li>
<li>Peak hour orders: 3 out of 3 (19:00, 20:45, 18:30 all in evening peak)</li>
<li>Peak hour percentage: 3/3 = 100% (at least 60%)&nbsp;</li>
<li>Rated orders: 3 out of 3 (100% rating completion)&nbsp;</li>
<li>Average rating: (5+4+5)/3 = 4.67 (at least 4.0)&nbsp;</li>
<li>Result: <strong>Golden hour customer</strong></li>
<li>总订单数:3(至少 3 笔)</li>
<li>高峰时间订单:3 笔中有 3 (19:0020:4518:30 都在傍晚高峰时间)</li>
<li>高峰时间占比:3/3 = 100%(至少 60%</li>
<li>已评分的订单:3 笔中有 3 笔(100% 评分完成率)</li>
<li>平均评分:(5+4+5)/3 = 4.67(至少 4.0</li>
<li>结果:<strong>黄金时段客户</strong></li>
</ul>
</li>
<li><strong>Customer 104</strong>:
<li><strong>客户 104</strong>:
<ul>
<li>Total orders: 3 (at least 3)&nbsp;</li>
<li>Peak hour orders: 0 out of 3 (10:00, 09:30, 16:00 all outside peak hours)</li>
<li>Peak hour percentage: 0/3 = 0% (less than 60%)&nbsp;</li>
<li>Result: <strong>Not a golden hour customer</strong> (insufficient peak hour orders)</li>
<li>总订单数:3(至少 3 笔)</li>
<li>高峰时间订单:3 笔中有 0 笔(10:0009:3016:00 都不在高峰时间)</li>
<li>高峰时间占比:0/3 = 0%(至少 60%</li>
<li>结果:<strong>不是黄金时段客户</strong>(高峰时段订单不足)</li>
</ul>
</li>
<li><strong>Customer 105</strong>:
<li><strong>客户 105</strong>:
<ul>
<li>Total orders: 3 (at least 3)&nbsp;</li>
<li>Peak hour orders: 3 out of 3 (12:15, 13:00, 11:45 all in lunch peak)</li>
<li>Peak hour percentage: 3/3 = 100% (at least 60%)&nbsp;</li>
<li>Rated orders: 3 out of 3 (100% rating completion)&nbsp;</li>
<li>Average rating: (4+5+4)/3 = 4.33 (at least 4.0)&nbsp;</li>
<li>Result: <strong>Golden hour customer</strong></li>
<li>总订单数:3(至少 3 笔)</li>
<li>高峰时间订单:3 笔中有 3 笔(12:1513:0011:45 都在中午高峰时间)</li>
<li>高峰时间占比:3/3 = 100%(至少 60%</li>
<li>已评分的订单:3 笔中有 3 笔(100% 评分完成率)</li>
<li>平均评分:(4+5+4)/3 = 4.33(至少 4.0</li>
<li>结果:<strong>黄金时段客户</strong></li>
</ul>
</li>

</ul>

<p>The results table is ordered by average_rating DESC, then customer_id DESC.</p>
<p>结果表按 average_rating 降序排序,然后按 customer_id 降序排序。</p>
</div>

<!-- description:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ order_timestamp contains both date and time information.
| customer_id | total_orders | peak_hour_percentage | average_rating |
+-------------+--------------+----------------------+----------------+
| 103 | 3 | 100 | 4.67 |
| 101 | 4 | 75 | 4.67 |
| 101 | 4 | 100 | 4.67 |
| 105 | 3 | 100 | 4.33 |
+-------------+--------------+----------------------+----------------+
</pre>
Expand All @@ -98,8 +98,8 @@ order_timestamp contains both date and time information.

<ul>
<li>Total orders: 4 (at least 3)&nbsp;</li>
<li>Peak hour orders: 3 out of 4 (12:30, 19:15, 13:45, and 20:30 are in peak hours)</li>
<li>Peak hour percentage: 3/4 = 75% (at least 60%)&nbsp;</li>
<li>Peak hour orders: 4 out of 4 (12:30, 19:15, 13:45, and 20:30 are in peak hours)</li>
<li>Peak hour percentage: 100% (at least 60%)&nbsp;</li>
<li>Rated orders: 3 out of 4 (75% rating completion)&nbsp;</li>
<li>Average rating: (5+4+5)/3 = 4.67 (at least 4.0)&nbsp;</li>
<li>Result: <strong>Golden hour customer</strong></li>
Expand Down
Loading