Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up

Check Whether Three Angles Form a Valid Triangle

Basic Acceptance 80.89% 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 sum is exactly 180 degrees.

Examples
Example 1

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

Example 2

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

Example 3

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

Constraints
  • 0 = a, b, c = 360
Companies
Amazon Visa
Topics
Data Structures Basics 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