Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update lc problems #2473

Merged
merged 1 commit into from
Mar 21, 2024
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
@@ -1,4 +1,4 @@
# [3060. User Activities within Time Bounds](https://leetcode.cn/problems/user-activities-within-time-bounds)
# [3060. 时间范围内的用户活动](https://leetcode.cn/problems/user-activities-within-time-bounds)

[English Version](/solution/3000-3099/3060.User%20Activities%20within%20Time%20Bounds/README_EN.md)

Expand All @@ -8,7 +8,7 @@

<!-- 这里写题目描述 -->

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

<pre>
+---------------+----------+
Expand All @@ -20,23 +20,24 @@
| session_id | int |
| session_type | enum |
+---------------+----------+
session_id is column of unique values for this table.
session_type is an ENUM (category) type of (Viewer, Streamer).
This table contains user id, session start, session end, session id and session type.
session_id 是这张表中有不同值的列。
session_type 是 (Viewer, Streamer) 的一个 ENUM (category) 类型。
这张表包含 user id, session start, session end, session id session 类型。
</pre>

<p>Write a solution to find the the <strong>users</strong> who have had <strong>at least one</strong> <strong>consecutive session</strong> of the <strong>same</strong> type (either &#39;<strong>Viewer</strong>&#39; or &#39;<strong>Streamer</strong>&#39;) with a <strong>maximum</strong> gap of <code>12</code> hours <strong>between</strong> sessions.</p>
<p>编写一个解决方案,以查找 <strong>至少有一个相同</strong> 类型的 <strong>连续会话</strong>(无论是“<strong>Viewer</strong>”还是“<strong>Streamer</strong>”)的 <strong>用户</strong>,会话 <strong>之间</strong><strong>最大</strong> 间隔为 <code>12</code> 小时。</p>

<p>Return <em>the result table ordered by </em><code>user_id</code><em> in <b>ascending</b> order.</em></p>
<p>返回结果表,以<em>&nbsp;</em><code>user_id</code><em>&nbsp;<strong>升序</strong> 排序。</em></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>

<pre>
<strong>Input:</strong>
Sessions table:
<strong>输入:</strong>
Sessions :
+---------+---------------------+---------------------+------------+--------------+
| user_id | session_start | session_end | session_id | session_type |
+---------+---------------------+---------------------+------------+--------------+
Expand All @@ -52,18 +53,18 @@ Sessions table:
| 103 | 2023-11-02 20:00:00 | 2023-11-02 23:00:00 | 10 | Viewer |
| 103 | 2023-11-03 09:00:00 | 2023-11-03 10:00:00 | 11 | Viewer |
+---------+---------------------+---------------------+------------+--------------+
<strong>Output:</strong>
<strong>输出:</strong>
+---------+
| user_id |
+---------+
| 102 |
| 103 |
+---------+
<strong>Explanation:</strong>
- User ID 101 will not be included in the final output as they do not have any consecutive sessions of the same session type.
- User ID 102 will be included in the final output as they had two viewer sessions with session IDs 3 and 4, respectively, and the time gap between them was less than 12 hours.
- User ID 103 participated in two viewer sessions with a gap of less than 12 hours between them, identified by session IDs 10 and 11. Therefore, user 103 will be included in the final output.
Output table is ordered by user_id in increasing order.
<strong>解释:</strong>
- 用户 ID 101 将不会包含在最终输出中,因为他们没有相同会话类型的连续回话。
- 用户 ID 102 将会包含在最终输出中,因为他们分别有两个 session ID 为 3 和 4 的 viewer 会话,并且时间间隔在 12 小时内。
- 用户 ID 103 参与了两次 viewer 会话,间隔不到 12 小时,会话 ID 为 10 11。因此,用户 103 将会被包含在最终输出中。
输出表根据 user_id 升序排列。
</pre>

## 解法
Expand Down
2 changes: 1 addition & 1 deletion solution/3000-3099/3063.Linked List Frequency/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<!-- 这里写题目描述 -->

<p>给定包含 <code>k</code> 个&nbsp;<strong>不同&nbsp;</strong>元素的链表的&nbsp;<code>head</code>&nbsp;节点,创建一个长度为&nbsp;<code>k</code>&nbsp;的链表,包含给定链表中每个 <strong>不同元素</strong> <strong>任何顺序</strong> 出现的 <span data-keyword="frequency-linkedlist">频率</span>&nbsp;。返回这个链表的头节点。</p>
<p>给定包含 <code>k</code> 个&nbsp;<strong>不同&nbsp;</strong>元素的链表的&nbsp;<code>head</code>&nbsp;节点,创建一个长度为&nbsp;<code>k</code>&nbsp;的链表, <strong>任何顺序</strong> 返回链表中所有 <strong>不同元素</strong> 出现的 <strong>频率</strong>。返回这个链表的头节点。</p>

<p>&nbsp;</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<p>给你一棵 <code>n</code>&nbsp;个节点的 <strong>无向</strong>&nbsp;树,节点从 <code>0</code>&nbsp;到 <code>n - 1</code>&nbsp;编号。树以长度为 <code>n - 1</code>&nbsp;下标从 <strong>0</strong>&nbsp;开始的二维整数数组 <code>edges</code>&nbsp;的形式给你,其中&nbsp;<code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>]</code>&nbsp;表示树中节点&nbsp;<code>u<sub>i</sub></code>&nbsp;和&nbsp;<code>v<sub>i</sub></code>&nbsp;之间有一条边。同时给你一个 <strong>正</strong>&nbsp;整数&nbsp;<code>k</code>&nbsp;和一个长度为 <code>n</code>&nbsp;下标从&nbsp;<strong>0</strong>&nbsp;开始的&nbsp;<strong>非负</strong>&nbsp;整数数组&nbsp;<code>nums</code>&nbsp;,其中&nbsp;<code>nums[i]</code>&nbsp;表示节点 <code>i</code>&nbsp;的 <strong>价值</strong>&nbsp;。</p>

<p>日增哥哥想 <strong>最大化</strong>&nbsp;树中所有节点价值之和。为了实现这一目标,日增哥哥可以执行以下操作 <strong>任意</strong>&nbsp;次(<strong>包括</strong><strong>&nbsp;0 次</strong>):</p>
<p>Alice&nbsp;想 <strong>最大化</strong>&nbsp;树中所有节点价值之和。为了实现这一目标,Alice 可以执行以下操作 <strong>任意</strong>&nbsp;次(<strong>包括</strong><strong>&nbsp;0 次</strong>):</p>

<ul>
<li>选择连接节点&nbsp;<code>u</code>&nbsp;和&nbsp;<code>v</code>&nbsp;的边&nbsp;<code>[u, v]</code>&nbsp;,并将它们的值更新为:
Expand All @@ -23,7 +23,7 @@

</ul>

<p>请你返回日增哥哥通过执行以上操作 <strong>任意次</strong>&nbsp;后,可以得到所有节点 <strong>价值之和</strong>&nbsp;的 <strong>最大值</strong>&nbsp;。</p>
<p>请你返回 Alice 通过执行以上操作 <strong>任意次</strong>&nbsp;后,可以得到所有节点 <strong>价值之和</strong>&nbsp;的 <strong>最大值</strong>&nbsp;。</p>

<p>&nbsp;</p>

Expand All @@ -34,7 +34,7 @@
<pre>
<b>输入:</b>nums = [1,2,1], k = 3, edges = [[0,1],[0,2]]
<b>输出:</b>6
<b>解释:</b>日增哥哥可以通过一次操作得到最大价值和 6 :
<b>解释:</b>Alice 可以通过一次操作得到最大价值和 6 :
- 选择边 [0,2] 。nums[0] 和 nums[2] 都变为:1 XOR 3 = 2 ,数组 nums 变为:[1,2,1] -&gt; [2,2,2] 。
所有节点价值之和为 2 + 2 + 2 = 6 。
6 是可以得到最大的价值之和。
Expand All @@ -47,7 +47,7 @@
<pre>
<b>输入:</b>nums = [2,3], k = 7, edges = [[0,1]]
<b>输出:</b>9
<b>解释:</b>日增哥哥可以通过一次操作得到最大和 9 :
<b>解释:</b>Alice 可以通过一次操作得到最大和 9 :
- 选择边 [0,1] 。nums[0] 变为:2 XOR 7 = 5 ,nums[1] 变为:3 XOR 7 = 4 ,数组 nums 变为:[2,3] -&gt; [5,4] 。
所有节点价值之和为 5 + 4 = 9 。
9 是可以得到最大的价值之和。
Expand All @@ -60,7 +60,7 @@
<pre>
<b>输入:</b>nums = [7,7,7,7,7,7], k = 3, edges = [[0,1],[0,2],[0,3],[0,4],[0,5]]
<b>输出:</b>42
<b>解释:</b>日增哥哥不需要执行任何操作,就可以得到最大价值之和 42 。
<b>解释:</b>Alice 不需要执行任何操作,就可以得到最大价值之和 42 。
</pre>

<p>&nbsp;</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/3000-3099/3078.Match%20Alphanumerical%20Pattern%20in%20Matrix%20I/README_EN.md)

<!-- tags: -->
<!-- tags:数组,哈希表,字符串,矩阵 -->

## 题目描述

Expand All @@ -15,8 +15,8 @@
<p>如果我们能用一些数字(每个 <strong>不同</strong> 的字母对应 <strong>不同</strong> 的数字)替换&nbsp;<code>pattern</code>&nbsp;中包含的字母使得结果矩阵与整数矩阵&nbsp;<code>part</code>&nbsp;相同,我们称整数矩阵&nbsp;<code>part</code>&nbsp;与&nbsp;<code>pattern</code>&nbsp;匹配。换句话说,</p>

<ul>
<li>矩阵具有相同的维数。</li>
<li>如果&nbsp;<code>pattern[r][c]</code>&nbsp;是一个数字,那么&nbsp;<code>part[r][c]</code>&nbsp;一定 <strong></strong> 是数字。</li>
<li>这两个矩阵具有相同的维数。</li>
<li>如果&nbsp;<code>pattern[r][c]</code>&nbsp;是一个数字,那么&nbsp;<code>part[r][c]</code>&nbsp;必须是&nbsp;<strong>相同的</strong> 数字。</li>
<li>如果&nbsp;<code>pattern[r][c]</code>&nbsp;是一个字母&nbsp;<code>x</code>:
<ul>
<li>对于每个&nbsp;<code>pattern[i][j] == x</code>,<code>part[i][j]</code>&nbsp;一定与 <code>part[r][c]</code>&nbsp;<strong>相同</strong>。</li>
Expand All @@ -25,7 +25,7 @@
</li>
</ul>

<p>返回一个长度为<em>&nbsp;</em><code>2</code>&nbsp;的数组,包含匹配&nbsp;<code>pattern</code>&nbsp;的&nbsp;<code>board</code>&nbsp;的子矩阵左上角的行号和列号。如果有一个以上这样的子矩阵,返回行号更小的子矩阵。如果依然相同,则返回列号更小的子矩阵。如果没有符合的答案,返回&nbsp;<code>[-1, -1]</code>。</p>
<p>返回一个长度为<em>&nbsp;</em><code>2</code>&nbsp;的数组,包含匹配&nbsp;<code>pattern</code>&nbsp;的&nbsp;<code>board</code>&nbsp;的子矩阵左上角的行号和列号。如果有多个这样的子矩阵,返回行号更小的子矩阵。如果依然有多个,则返回列号更小的子矩阵。如果没有符合的答案,返回&nbsp;<code>[-1, -1]</code>。</p>

<p>&nbsp;</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/3000-3099/3078.Match%20Alphanumerical%20Pattern%20in%20Matrix%20I/README.md)

<!-- tags: -->
<!-- tags:Array,Hash Table,String,Matrix -->

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/3000-3099/3079.Find%20the%20Sum%20of%20Encrypted%20Integers/README_EN.md)

<!-- tags: -->
<!-- tags:数组,数学 -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/3000-3099/3079.Find%20the%20Sum%20of%20Encrypted%20Integers/README.md)

<!-- tags: -->
<!-- tags:Array,Math -->

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/3000-3099/3080.Mark%20Elements%20on%20Array%20by%20Performing%20Queries/README_EN.md)

<!-- tags: -->
<!-- tags:数组,哈希表,排序,模拟,堆(优先队列) -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/3000-3099/3080.Mark%20Elements%20on%20Array%20by%20Performing%20Queries/README.md)

<!-- tags: -->
<!-- tags:Array,Hash Table,Sorting,Simulation,Heap (Priority Queue) -->

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/3000-3099/3081.Replace%20Question%20Marks%20in%20String%20to%20Minimize%20Its%20Value/README_EN.md)

<!-- tags: -->
<!-- tags:贪心,哈希表,字符串,计数,排序,堆(优先队列) -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/3000-3099/3081.Replace%20Question%20Marks%20in%20String%20to%20Minimize%20Its%20Value/README.md)

<!-- tags: -->
<!-- tags:Greedy,Hash Table,String,Counting,Sorting,Heap (Priority Queue) -->

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/3000-3099/3082.Find%20the%20Sum%20of%20the%20Power%20of%20All%20Subsequences/README_EN.md)

<!-- tags: -->
<!-- tags:数组,动态规划 -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/3000-3099/3082.Find%20the%20Sum%20of%20the%20Power%20of%20All%20Subsequences/README.md)

<!-- tags: -->
<!-- tags:Array,Dynamic Programming -->

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/3000-3099/3083.Existence%20of%20a%20Substring%20in%20a%20String%20and%20Its%20Reverse/README_EN.md)

<!-- tags: -->
<!-- tags:哈希表,字符串 -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/3000-3099/3083.Existence%20of%20a%20Substring%20in%20a%20String%20and%20Its%20Reverse/README.md)

<!-- tags: -->
<!-- tags:Hash Table,String -->

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/3000-3099/3084.Count%20Substrings%20Starting%20and%20Ending%20with%20Given%20Character/README_EN.md)

<!-- tags: -->
<!-- tags:数学,字符串,计数 -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/3000-3099/3084.Count%20Substrings%20Starting%20and%20Ending%20with%20Given%20Character/README.md)

<!-- tags: -->
<!-- tags:Math,String,Counting -->

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/3000-3099/3085.Minimum%20Deletions%20to%20Make%20String%20K-Special/README_EN.md)

<!-- tags: -->
<!-- tags:贪心,哈希表,字符串,计数,排序 -->

## 题目描述

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[中文文档](/solution/3000-3099/3085.Minimum%20Deletions%20to%20Make%20String%20K-Special/README.md)

<!-- tags: -->
<!-- tags:Greedy,Hash Table,String,Counting,Sorting -->

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English Version](/solution/3000-3099/3086.Minimum%20Moves%20to%20Pick%20K%20Ones/README_EN.md)

<!-- tags: -->
<!-- tags:贪心,数组,前缀和,滑动窗口 -->

## 题目描述

Expand Down
Loading
Loading