<reponame>ardakkk/Algorithms-and-Data-Structures<filename>algorithms-implementation/array/find-pythagorean-triplets.py
def findPythagoreanTriplets(nums):
    for a in nums:
        for b in nums:
            for c in nums:
                if a*a + b*b = c*c:
                    return True
    return False

# Time: O(n^2)
# Space: O(n)
def findPythagoreanTriplets2(nums):
    squares = set([n*n for n in nums])

    for a in nums:
        for b in nums:
            if a*a + b*b in squares:
                return True
    return False
def findPythagoreanTriplets(nums):
    for a in nums:
        for b in nums:
            for c in nums:
                if a*a + b*b = c*c:
                    return True
    return False

# Time: O(n^2)
# Space: O(n)
def findPythagoreanTriplets2(nums):
    squares = set([n*n for n in nums])

    for a in nums:
        for b in nums:
            if a*a + b*b in squares:
                return True
    return False
# Time: O(n^2) # Space: O(n)