Skip to content

Commit 9ade738

Browse files
committed
feat: add sql solution to lc problem: No.1767
No.1767.Find the Subtasks That Did Not Execute
1 parent 00e9e40 commit 9ade738

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

solution/1700-1799/1767.Find the Subtasks That Did Not Execute/README.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,39 @@ Task 3 被分成了 4 subtasks (1, 2, 3, 4)。所有的subtask都被成功执行
8686

8787
<!-- 这里可写通用的实现逻辑 -->
8888

89+
**方法一:递归生成数据表**
90+
8991
<!-- tabs:start -->
9092

9193
### **SQL**
9294

9395
<!-- 这里可写当前语言的特殊实现逻辑 -->
9496

9597
```sql
96-
98+
# Write your MySQL query statement below
99+
with recursive t(task_id, subtask_id) as (
100+
select
101+
task_id,
102+
subtasks_count
103+
from
104+
Tasks
105+
union
106+
all
107+
select
108+
task_id,
109+
subtask_id - 1
110+
from
111+
t
112+
where
113+
subtask_id >= 2
114+
)
115+
select
116+
t.*
117+
from
118+
t
119+
left join Executed e using(task_id, subtask_id)
120+
where
121+
e.subtask_id is null
97122
```
98123

99124
<!-- tabs:end -->

solution/1700-1799/1767.Find the Subtasks That Did Not Execute/README_EN.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,30 @@ Task 3 was divided into 4 subtasks (1, 2, 3, 4). All of the subtasks were execut
8686
### **SQL**
8787

8888
```sql
89-
89+
# Write your MySQL query statement below
90+
with recursive t(task_id, subtask_id) as (
91+
select
92+
task_id,
93+
subtasks_count
94+
from
95+
Tasks
96+
union
97+
all
98+
select
99+
task_id,
100+
subtask_id - 1
101+
from
102+
t
103+
where
104+
subtask_id >= 2
105+
)
106+
select
107+
t.*
108+
from
109+
t
110+
left join Executed e using(task_id, subtask_id)
111+
where
112+
e.subtask_id is null
90113
```
91114

92115
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Write your MySQL query statement below
2+
with recursive t(task_id, subtask_id) as (
3+
select
4+
task_id,
5+
subtasks_count
6+
from
7+
Tasks
8+
union
9+
all
10+
select
11+
task_id,
12+
subtask_id - 1
13+
from
14+
t
15+
where
16+
subtask_id >= 2
17+
)
18+
select
19+
t.*
20+
from
21+
t
22+
left join Executed e using(task_id, subtask_id)
23+
where
24+
e.subtask_id is null

0 commit comments

Comments
 (0)