#-------------------------------------------------------------------------------
# Name: Single Number
# Purpose:
#
# Given an array of integers, every element appears twice except for one.
# Find that single one.
#
# Note:
# Your algorithm should have a linear runtime complexity.
# Could you implement it without using extra memory?
#-------------------------------------------------------------------------------
def singleNumber(A):
return reduce(operator.xor, A)
#-------------------------------------------------------------------------------
# Name: Add Binary
# Purpose:
# Given two binary strings, return their sum (also a binary string).
#
# For example,
# a = "11"
# b = "1"
# Return "100".
#-------------------------------------------------------------------------------
def addBinary(a, b):
summ = 0
for n in [a, b]:
rst = 0
for x in n:
rst = rst*2 + int(x)
summ += rst
return bin(summ)[2:]