Given three integers a, b and c. The task is to check if it is possible to make right angled triangle with sides of length a, b and c.
 
Example 1:
Input:
a = 3, b = 4, c = 5
Output:
Yes
Explanation:
We can form a right angled triangle
with sides of length 3, 4 and 5.
Example 2:
Input:
a = 2, b = 5, c = 8
Output:
No
Explanation:
We can't form a right angled triangle
with sides of length 2, 5 and 8.
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function rightAngTri() which takes 3 Integers a,b and c as input and returns "Yes" if it is possible to form a right angled triangle with sides of length a, b, and c, else return "No".
 
Expected Time Complexity: O(log(max(a,b,c)))
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= a,b,c <= 10^{8}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def rightAngTri(self, a, b, c):

        # code here 

Solutions:
import math

class Solution:

	def rightAngTri(self, a, b, c):
		if a * a + b * b == c * c or a * a + c * c == b * b or b * b + c * c == a * a:
			return 'Yes'
		return 'No'


class Solution:

	def rightAngTri(self, a, b, c):
		lst = [a, b, c]
		lst = sorted(lst)
		if lst[0] ** 2 + lst[1] ** 2 == lst[2] ** 2:
			return 'Yes'
		return 'No'


class Solution:

	def rightAngTri(self, a, b, c):
		if a ** 2 + b ** 2 == c ** 2 or a ** 2 + c ** 2 == b ** 2 or c ** 2 + b ** 2 == a ** 2:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def rightAngTri(self, a, b, c):
		arr = []
		arr.append(a)
		arr.append(b)
		arr.append(c)
		z = arr.pop(arr.index(max(arr)))
		x = arr[0]
		y = arr[1]
		if x ** 2 + y ** 2 == z ** 2:
			return 'Yes'
		else:
			return 'No'


class Solution:

	def rightAngTri(self, a, b, c):
		l = [a, b, c]
		l.sort()
		if l[0] * l[0] + l[1] * l[1] == l[2] * l[2]:
			return 'Yes'
		return 'No'


class Solution:

	def rightAngTri(self, a, b, c):
		x = a * a
		y = b * b
		z = c * c
		if x + y == z or y + z == x or z + x == y:
			return 'Yes'
		return 'No'