# Given an int array nums and an int target, find how many unique pairs in the array such that their sum is equal to target. Return the number of pairs.

# Example 1:
# Input: nums = [1, 1, 2, 45, 46, 46], target = 47
# Output: 2
# Explanation:
# 1 + 46 = 47
# 2 + 45 = 47

# Example 2:
# Input: nums = [1, 1], target = 2
# Output: 1
# Explanation:
# 1 + 1 = 2

# Example 3:
# Input: nums = [1, 5, 1, 5], target = 6
# Output: 1
# Explanation:
# [1, 5] and [5, 1] are considered the same.

def uniqueTwoSum(nums, target):
  ans, comp = set(), set()
  for n in nums:
    c = target-n
    if c in comp:
      res = (n, c) if n > c else (c, n)
      if res not in ans:
        ans.add(res)
    comp.add(n)
  return len(ans)
  
65c011fe77dc5e6193a27964c4a53ce45b025612
<mask token>

def uniqueTwoSum(nums, target):
    ans, comp = set(), set()
    for n in nums:
        c = target - n
        if c in comp:
            res = (n, c) if n > c else (c, n)
            if res not in ans:
                ans.add(res)
        comp.add(n)
    return len(ans)

# Given an int array nums and an int target, find how many unique pairs in the array such that their sum is equal to target. Return the number of pairs.

# Example 1:
# Input: nums = [1, 1, 2, 45, 46, 46], target = 47
# Output: 2
# Explanation:
# 1 + 46 = 47
# 2 + 45 = 47

# Example 2:
# Input: nums = [1, 1], target = 2
# Output: 1
# Explanation:
# 1 + 1 = 2

# Example 3:
# Input: nums = [1, 5, 1, 5], target = 6
# Output: 1
# Explanation:
# [1, 5] and [5, 1] are considered the same.

def uniqueTwoSum(nums, target):
  ans, comp = set(), set()
  for n in nums:
    c = target-n
    if c in comp:
      res = (n, c) if n > c else (c, n)
      if res not in ans:
        ans.add(res)
    comp.add(n)
  return len(ans)
  