Skip to content

Commit 4ae590f

Browse files
committed
[LeetCode Sync] Runtime - 259 ms (89.71%), Memory - 0.0B (100.00%)
1 parent 95372b1 commit 4ae590f

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<p>Table: <code>Triangle</code></p>
2+
3+
<pre>
4+
+-------------+------+
5+
| Column Name | Type |
6+
+-------------+------+
7+
| x | int |
8+
| y | int |
9+
| z | int |
10+
+-------------+------+
11+
In SQL, (x, y, z) is the primary key column for this table.
12+
Each row of this table contains the lengths of three line segments.
13+
</pre>
14+
15+
<p>&nbsp;</p>
16+
17+
<p>Report for every three line segments whether they can form a triangle.</p>
18+
19+
<p>Return the result table in <strong>any order</strong>.</p>
20+
21+
<p>The&nbsp;result format is in the following example.</p>
22+
23+
<p>&nbsp;</p>
24+
<p><strong class="example">Example 1:</strong></p>
25+
26+
<pre>
27+
<strong>Input:</strong>
28+
Triangle table:
29+
+----+----+----+
30+
| x | y | z |
31+
+----+----+----+
32+
| 13 | 15 | 30 |
33+
| 10 | 20 | 15 |
34+
+----+----+----+
35+
<strong>Output:</strong>
36+
+----+----+----+----------+
37+
| x | y | z | triangle |
38+
+----+----+----+----------+
39+
| 13 | 15 | 30 | No |
40+
| 10 | 20 | 15 | Yes |
41+
+----+----+----+----------+
42+
</pre>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SELECT x, y, z,
2+
IF (x + y > z AND x + z > y AND y + z > x, "Yes", "No") AS triangle
3+
FROM Triangle

0 commit comments

Comments
 (0)