
Problem
Solution
Submissions
Check if a Triangle is Valid Given Its Three Angles
Certification: Basic Level
Accuracy: 41.67%
Submissions: 84
Points: 5
Write a Python program that determines whether three given angles can form a valid triangle.
Example 1
- Input: angles = [60, 60, 60]
- Output: True
- Explanation:
- Step 1: Check if all angles are greater than 0. Yes, all are 60 > 0.
- Step 2: Check if the sum of angles equals 180. 60 + 60 + 60 = 180. Yes.
- Step 3: Since both conditions are met, return True.
Example 2
- Input: angles = [90, 30, 0]
- Output: False
- Explanation:
- Step 1: Check if all angles are greater than 0. No, one angle is 0.
- Step 2: Even though the sum 90 + 30 + 0 = 120 (≠ 180), we return False because one angle is 0.
Constraints
- 0 ≤ angle ≤ 180
- Time Complexity: O(1)
- Space Complexity: O(1)
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
Solution Hints
- Check if all angles are greater than 0
- Verify the sum of angles equals exactly 180 degrees