2022-03-27 20:56:26 +08:00
|
|
|
|
<p>表:<code>Logs</code></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
+-------------+---------+
|
|
|
|
|
| Column Name | Type |
|
|
|
|
|
+-------------+---------+
|
|
|
|
|
| id | int |
|
|
|
|
|
| num | varchar |
|
|
|
|
|
+-------------+---------+
|
2023-12-09 18:42:21 +08:00
|
|
|
|
在 SQL 中,id 是该表的主键。
|
|
|
|
|
id 是一个自增列。</pre>
|
2022-03-27 20:56:26 +08:00
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p>找出所有至少连续出现三次的数字。</p>
|
2022-03-27 20:56:26 +08:00
|
|
|
|
|
|
|
|
|
<p>返回的结果表中的数据可以按 <strong>任意顺序</strong> 排列。</p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p>结果格式如下面的例子所示:</p>
|
2022-03-27 20:56:26 +08:00
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>
|
|
|
|
|
Logs 表:
|
|
|
|
|
+----+-----+
|
2023-12-09 18:42:21 +08:00
|
|
|
|
| id | num |
|
2022-03-27 20:56:26 +08:00
|
|
|
|
+----+-----+
|
|
|
|
|
| 1 | 1 |
|
|
|
|
|
| 2 | 1 |
|
|
|
|
|
| 3 | 1 |
|
|
|
|
|
| 4 | 2 |
|
|
|
|
|
| 5 | 1 |
|
|
|
|
|
| 6 | 2 |
|
|
|
|
|
| 7 | 2 |
|
|
|
|
|
+----+-----+
|
|
|
|
|
<strong>输出:</strong>
|
|
|
|
|
Result 表:
|
|
|
|
|
+-----------------+
|
|
|
|
|
| ConsecutiveNums |
|
|
|
|
|
+-----------------+
|
|
|
|
|
| 1 |
|
|
|
|
|
+-----------------+
|
|
|
|
|
<strong>解释:</strong>1 是唯一连续出现至少三次的数字。</pre>
|