Solutions for Element Appears Once

    • @Victorfreef
    • @Liam, submitted in Python 2, achived 100% score
    
    def solve(arr):
        start=0
        end=len(arr)-1
        mid=(start+end)//2
    
        if start == end:
            return arr[start]
    
        while(start<=end):
            if arr[start]==arr[start+1]:
                start+=2
            else:
                return arr[start]
            if arr[end]==arr[end-1]:
                end=end-2
            else:
                return arr[end]
    • @Victorfreef
    • @Liam, submitted in Python 3, achived 100% score
    
    def solve(arr):
        start=0
        end=len(arr)-1
        mid=(start+end)//2
    
        if start == end:
            return arr[start]
    
        while(start<=end):
            if arr[start]==arr[start+1]:
                start+=2
            else:
                return arr[start]
            if arr[end]==arr[end-1]:
                end=end-2
            else:
                return arr[end]