Given an integer C, the task is to find all possible pairs (A, B) in range [1, C) such that:
- A2 + B2 = C2
- A < B
Input: C = 5
(3)2 + (4)2 = 9 + 16 = 25 = 52
Input: C = 25
Output:(15, 20), (7, 24)
Explanation: Both the pairs satisfy the necessary conditions.
- Check all possible values of A and B in the range [1, C).
- Store all pair that satisfies the given conditions.
Below is the implementation of the above approach:
Time Complexity: O(C2)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Pythagorean Triplet with given sum
- Pythagorean Triplet with given sum using single loop
- Forming smallest array with given constraints
- Generate Pythagorean Triplets
- Check if a number is a Pythagorean Prime or not
- Twin Pythagorean triplets in an array
- Forming triangles using points on a square
- Count of ways to split N into Triplets forming a Triangle
- Count of subarrays forming an Arithmetic Progression (AP)
- Longest subarray forming an Arithmetic Progression (AP)
- Longest subarray forming a Geometic Progression (GP)
- Count subarrays of atleast size 3 forming a Geometric Progression (GP)
- Longest subsequence forming an Arithmetic Progression (AP)
- Sort decreasing permutation of N using triple swaps
- Find the maximum possible value of a[i] % a[j] over all pairs of i and j
- Minimum possible value T such that at most D Partitions of the Array having at most sum T is possible
- Find the maximum possible value of the minimum value of modified array
- Minimum value possible of a given function from the given set
- Given GCD G and LCM L, find number of possible pairs (a, b)
- Find all Pairs possible from the given Array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.