Pythagorean Triplet
Submissions: 29771   Accuracy:

38.09%

  Difficulty: Basic   Marks: 1
     

Given an array of integers, write a function that returns true if there is a triplet (a, b, c) that satisfies a2 + b2 = c2.

Input:
The first line contains 'T' denoting the number of testcases. Then follows description of testcases.
Each case begins with a single positive integer N denoting the size of array.
The second line contains the N space separated positive integers denoting the elements of array A.

Output:
For each testcase, print "Yes" or  "No" whtether it is Pythagorean Triplet or not (without quotes).

Constraints:
1 <= T <= 100
1 <= N <= 107
1 <= A[i] <= 1000

Example:
Input:
1
5
3 2 4 6 5
Output:
Yes

Explanation:
For testcase1: a=3, b=4, and c=5 forms a pythagorean triplet, so we print "Yes"

** For More Input/Output Examples Use 'Expected Output' option **

Author: Karan Grover


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.