VOOZH about

URL: https://www.geeksforgeeks.org/dsa/check-if-a-triangle-of-positive-area-is-possible-with-the-given-angles/

⇱ Check if a triangle of positive area is possible with the given angles - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Check if a triangle of positive area is possible with the given angles

Last Updated : 29 Jun, 2022

Given three angles. The task is to check if it is possible to have a triangle of positive area with these angles. If it is possible print "YES" else print "NO".
Examples
 

Input : ang1 = 50, ang2 = 60, ang3 = 70 
Output : YES

Input : ang1 = 50, ang2 = 65, ang3 = 80
Output : NO


 


Approach: We can form a valid triangle if the below conditions satisfies: 
 

  • The sum of the three given angles equals to 180.
  • The sum of any two angles is greater than equal to the third one.
  • None of the given angles is zero.


Below is the implementation of the above approach: 
 


Output: 
YES

 

Time complexity: O(1)

Auxiliary Space: O(1)

Comment
Article Tags:
Article Tags: