|
| 1 | +<h2><a href="https://leetcode.com/problems/type-of-triangle">3321. Type of Triangle</a></h2><h3>Easy</h3><hr><p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> of size <code>3</code> which can form the sides of a triangle.</p> |
| 2 | + |
| 3 | +<ul> |
| 4 | + <li>A triangle is called <strong>equilateral</strong> if it has all sides of equal length.</li> |
| 5 | + <li>A triangle is called <strong>isosceles</strong> if it has exactly two sides of equal length.</li> |
| 6 | + <li>A triangle is called <strong>scalene</strong> if all its sides are of different lengths.</li> |
| 7 | +</ul> |
| 8 | + |
| 9 | +<p>Return <em>a string representing</em> <em>the type of triangle that can be formed </em><em>or </em><code>"none"</code><em> if it <strong>cannot</strong> form a triangle.</em></p> |
| 10 | + |
| 11 | +<p> </p> |
| 12 | +<p><strong class="example">Example 1:</strong></p> |
| 13 | + |
| 14 | +<pre> |
| 15 | +<strong>Input:</strong> nums = [3,3,3] |
| 16 | +<strong>Output:</strong> "equilateral" |
| 17 | +<strong>Explanation:</strong> Since all the sides are of equal length, therefore, it will form an equilateral triangle. |
| 18 | +</pre> |
| 19 | + |
| 20 | +<p><strong class="example">Example 2:</strong></p> |
| 21 | + |
| 22 | +<pre> |
| 23 | +<strong>Input:</strong> nums = [3,4,5] |
| 24 | +<strong>Output:</strong> "scalene" |
| 25 | +<strong>Explanation:</strong> |
| 26 | +nums[0] + nums[1] = 3 + 4 = 7, which is greater than nums[2] = 5. |
| 27 | +nums[0] + nums[2] = 3 + 5 = 8, which is greater than nums[1] = 4. |
| 28 | +nums[1] + nums[2] = 4 + 5 = 9, which is greater than nums[0] = 3. |
| 29 | +Since the sum of the two sides is greater than the third side for all three cases, therefore, it can form a triangle. |
| 30 | +As all the sides are of different lengths, it will form a scalene triangle. |
| 31 | +</pre> |
| 32 | + |
| 33 | +<p> </p> |
| 34 | +<p><strong>Constraints:</strong></p> |
| 35 | + |
| 36 | +<ul> |
| 37 | + <li><code>nums.length == 3</code></li> |
| 38 | + <li><code>1 <= nums[i] <= 100</code></li> |
| 39 | +</ul> |
0 commit comments