Pythagorean Triples
Given an integer array, find all Pythagorean triples.
Statement
Given an integer array, find all Pythagorean triples ( + = ), where , and are the array elements.
Example
Here is a sample array.
Sample input
[4, 16, 1, 2, 3, 5, 6, 8, 25, 10]
Expected output
[[3, 4, 5], [6, 8, 10]]
The triples are calculated as:
+ = and + |
---|
Access this course and 1400+ top-rated courses and projects.