<reponame>vincent507cpu/Comprehensive-Algorithm-Solution<gh_stars>1-10
# https://leetcode.com/problems/fair-candy-swap/discuss/161269/C%2B%2BJavaPython-Straight-Forward

class Solution:
    def fairCandySwap(self, A: List[int], B: List[int]) -> List[int]:
        diff = (sum(A) - sum(B)) // 2
        B = set(B)
        A = set(A)
        
        for b in B:
            if b + diff in A:
                return [b+diff, b]
# https://leetcode.com/problems/fair-candy-swap/discuss/161269/C%2B%2BJavaPython-Straight-Forward

class Solution:
    def fairCandySwap(self, A: List[int], B: List[int]) -> List[int]:
        diff = (sum(A) - sum(B)) // 2
        B = set(B)
        A = set(A)
        
        for b in B:
            if b + diff in A:
                return [b+diff, b]
# https://leetcode.com/problems/fair-candy-swap/discuss/161269/C%2B%2BJavaPython-Straight-Forward