Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up

Check Whether Three Angles Form a Valid Triangle

Acceptance 91.52% Points 10.00

You are given three angles in degrees. Your task is to determine whether they can form a valid triangle.

The angles are valid if each angle is greater than 0 and their total is exactly 180°.

Examples
Example 1

image Input: a = 60, b = 60, c = 60
Output: Valid
Explanation: The angles are all positive and sum to 180°.

Example 2

image Input: a = 90, b = 60, c = 40
Output: Invalid
Explanation: The angles sum to 190°, not 180°.

Example 3

image Input: a = 0, b = 90, c = 90
Output: Invalid
Explanation: An angle of cannot exist in a triangle.

Constraints
    • 0 = each angle = 360°
Companies
Cisco PhonePe
Topics
Comparisons
Solution.cs C#JavaPythonC++Javascript

Unlock the code editor

Sign in to write, run, and submit your solution against the full test suite.

  • Run code against sample & hidden test cases
  • Save submissions and track your streak
  • Compare with editorial & community solutions