# Problem here -> https://www.geeksforgeeks.org/find-pythagorean-triplet-in-an-unsorted-array/ nums = [10, 4, 6, 12, 5] found = False for x in range(0, len(nums)): nums[x] *= nums[x] nums.sort() checker = len(nums) - 1 while (checker > 1): ele = nums[checker] a, b = 0, checker - 1 while a < b: trip_sum = nums[a] + nums[b] if trip_sum == ele: print("Found") found = True break if trip_sum < ele: a+=1 else: b-= 1 checker -= 1 if not found: print("Not Found!") # Time complexity -> O(n^2) # space complexity -> O(1)