Classify Every Triple by the Strict Triangle Inequalities
Quick Overview
For every Triangle row, return x, y, z and triangle, labeled Yes when the three segment lengths form a triangle and No otherwise. Preserve all input triples; row order is unrestricted.
Classify Every Triple by the Strict Triangle Inequalities
Company: Microsoft
Role: Software Engineer
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
### Problem
For every Triangle row, return x, y, z and triangle, labeled Yes when the three segment lengths form a triangle and No otherwise. Preserve all input triples; row order is unrestricted.
### Tables
Table: `Triangle`
```text
+-------------+------+
| Column Name | Type |
+-------------+------+
| x | int |
| y | int |
| z | int |
+-------------+------+
In SQL, (x, y, z) is the primary key column for this table.
Each row of this table contains the lengths of three line segments.
```
### Example
```text
Triangle (x,y,z): (3,4,5), (2,3,5)
Output (x,y,z,triangle): (3,4,5,Yes), (2,3,5,No)
```
### What a Strong Answer Covers
- Check each triple and return the specified Yes or No label.
- Reject triples that only meet an equality boundary and preserve all input rows.
### Follow-up Questions
- How would you classify valid triangles by their side lengths?
- How would you avoid overflow if side lengths could use the entire integer range?
Overview: For every Triangle row, return x, y, z and triangle, labeled Yes when the three segment lengths form a triangle and No otherwise. Preserve all input triples; row order is unrestricted.
For every Triangle row, return x, y, z and triangle, labeled Yes when the three segment lengths form a triangle and No otherwise. Preserve all input triples; row order is unrestricted.
Tables
Table: Triangle
+-------------+------+
| Column Name | Type |
+-------------+------+
| x | int |
| y | int |
| z | int |
+-------------+------+
In SQL, (x, y, z) is the primary key column for this table.
Each row of this table contains the lengths of three line segments.