#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 10 18:40:03 2016

@author: Steven
Given an array of integers, every element appears twice except for one.
Write a function that finds the unique element.
"""
class Solution(object):
    def singleNumber(self, nums):
 
        for i in range(0,len(nums),2):
            if (i != len(nums) - 1) and (nums[i] != nums[i+1]): 
                print (nums[i])
            elif i == len(nums) - 1:
                print (nums[i])
    
def main():
    nums=[1,1,2,2,3]
    s=Solution()
    s.singleNumber(nums)
    print('done')
   
main()

"""iterate through the list, by every two element. Compare each element to
previous element and if i+1th != ith then print the element. If we traverse 
until the last element, it must be the last element.
"""