当前位置:网站首页>Leetcode 180 Consecutive numbers (2022.06.29)
Leetcode 180 Consecutive numbers (2022.06.29)
2022-06-30 05:00:00 【ChaoYue_ miku】
surface :Logs
±------------±--------+
| Column Name | Type |
±------------±--------+
| id | int |
| num | varchar |
±------------±--------+
id It's the primary key of this table .
Write a SQL Inquire about , Find all numbers that appear at least three times in a row .
The data in the returned result table can be displayed by In any order array .
The query result format is shown in the following example :
Example 1:
Input :
Logs surface :
±—±----+
| Id | Num |
±—±----+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
| 5 | 1 |
| 6 | 2 |
| 7 | 2 |
±—±----+
Output :
Result surface :
±----------------+
| ConsecutiveNums |
±----------------+
| 1 |
±----------------+
explain :1 Is the only number that appears at least three times in a row .
source : Power button (LeetCode)
link :https://leetcode.cn/problems/consecutive-numbers
Method 1 : Use DISTINCT
MySQL Submission :
# Write your MySQL query statement below
SELECT DISTINCT
l1.Num AS ConsecutiveNums
FROM
Logs l1,
Logs l2,
Logs l3
WHERE
l1.Id = l2.Id - 1
AND l2.Id = l3.Id - 1
AND l1.Num = l2.Num
AND l2.Num = l3.Num
;
边栏推荐
- Check London attractions suitable for parents and children in winter vacation
- 【Paper】2020_ Research on defense and evaluation strategy of heterogeneous UAV formation_ Zuojiankai
- UnityEngine. JsonUtility. The pit of fromjason()
- C # equipment synthesis
- PBR material: basic principle and simple fabrication
- Keywords implements and @override
- 【Paper】2019_ Distributed Cooperative Control of a High-speed Train
- 【Paper】2021_ Analysis of the Consensus Protocol of Heterogeneous Agents with Time-Delays
- The golden deer, a scenic spot in London -- a sailing museum that tells vivid sailing stories
- [UAV] kinematic analysis from single propeller to four rotor UAV
猜你喜欢

Collective system

A must see cruise experience in Bangkok: visit the Mekong River and enjoy the scenery on both sides of the river

【Paper】2021_ Analysis of the Consensus Protocol of Heterogeneous Agents with Time-Delays

What is multimodal interaction?

【VCS+Verdi联合仿真】~ 以计数器为例

Redis cluster concept

力扣59. 螺旋矩阵 II

Autowired注解警告的解决办法

【Paper】2019_ Consensus Control of Multiple AUVs Recovery System Under Switching Topologies and Time D

Basic operations of Oracle data
随机推荐
深度学习------不同方法实现Inception-10
Li Kou 2049: count the number of nodes with the highest score
Redis cluster concept
Sailing experience not to be missed in New York Tourism: take you to enjoy the magnificent city scenery from different perspectives
Steamvr causes abnormal scene camera
【Paper】2021_ Uniformity of heterogeneous hybrid multi-level intelligent systems using UGV and UAV
Important knowledge points in unity3d
Qos(Quality of Service)
Detailed explanation of the process of "flyingbird" small game (camera adjustment and following part)
Harbor API 2.0 query
Unity profiler performance analysis
Pycharm database tool
【Paper】2020_ Research on defense and evaluation strategy of heterogeneous UAV formation_ Zuojiankai
【Paper】2021_ Observer-Based Controllers for Incrementally Quadratic Nonlinear Systems With Disturbanc
Unity automatic pathfinding
A must see cruise experience in Bangkok: visit the Mekong River and enjoy the scenery on both sides of the river
【Paper】2015_ Coordinated cruise control for high-speed train movements based on a multi-agent model
Keywords implements and @override
[control] multi agent system summary. 5. system consolidation.
Spring Festival Tourism Strategy: welcome the new year in Bangkok, Thailand