当前位置:网站首页>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
;
边栏推荐
- Qos(Quality of Service)
- 力扣704. 二分查找
- Error about the new version of UE4: unavigationsystemv1:: simplemovetoactor has been deprecated
- Royal Albert Hall, a popular landmark in London
- Redis cluster concept
- Have a heart beating Valentine's day in Singapore
- redis集群概念
- Force buckle 349 Intersection of two arrays
- LxC and LXD container summary
- Collective system
猜你喜欢

redis集群概念

Pycharm database tool

力扣2049:统计最高分的节点数目

Efficiency test of adding and querying ArrayList and LinkedList

PS1 Contemporary Art Center, Museum of modern art, New York

Force buckle 59 Spiral matrix II

力扣704. 二分查找

Connect() and disconnect() of socket in C #

【Paper】2019_ Distributed Cooperative Control of a High-speed Train

Qos(Quality of Service)
随机推荐
Draw on screen border in Commodore 64
Force buckle 27 Removing Elements
[control] multi agent system summary. 5. system consolidation.
Some books you should not miss when you are new to the workplace
【Paper】2015_ Coordinated cruise control for high-speed train movements based on a multi-agent model
Introduction to some representations, neighbors and degrees of Graphs
Brew install NVM command not found solution
Solution to 293 problems in the week of Li Kou
Unity multiple UI page turning left and right
Deep learning ----- different methods to realize inception-10
Unity automatic pathfinding
Singapore parent-child tour, these popular attractions must be arranged
【Paper】2017_ Research on coordinated control method of underwater vehicle formation marine survey
力扣27. 移除元素
Autowired注解警告的解决办法
Unity Logitech steering wheel access
PS1 Contemporary Art Center, Museum of modern art, New York
力扣292周赛题解
MySQL query gadget (I) replace a property value of the object in the JSON array in the JSON format string field
Parkour demo