human
Possible to form a triangle from array values | Method prints possible triangle when array values are taken as sides.
If number of elements are less than 3 , then no triangle is possible.
first sort the array.
loop for all 3 consecutive triplets.
If triplet satisfies triangle condition , break.
Driver Code"
How can the above be solved in Python?
 Write me a code to possible to form a triangle from array values and the other steps required?
assistant
#Here is code to possible to form a triangle from array values and the other steps required.
 def isPossibleTriangle ( arr , N ) :
	if N < 3 :
		return False
	arr . sort ( )
	for i in range ( N - 2 ) :
		if arr [ i ] + arr [ i + 1 ] > arr [ i + 2 ] :
			return True
arr = [ 5 , 4 , 3 , 1 , 2 ]
N = len ( arr )
print ( " Yes " if isPossibleTriangle ( arr , N ) else " No " )