Skip to content

Commit 541e304

Browse files
authored
Update Shortest Distance.sql
1 parent 76d4719 commit 541e304

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Easy/Shortest Distance.sql

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,17 @@ select min(abs(abs(a.x)-abs(a.next_closest))) as shortest
2727
from(
2828
select *,
2929
lead(x) over(order by x) as next_closest
30-
from point) a
30+
from point) a
31+
32+
33+
My sol:
34+
35+
select min(abs(a.x - b.x)) as shortest
36+
from point a cross join point b
37+
where b.x > a.x
38+
39+
40+
41+
42+
43+

0 commit comments

Comments
 (0)