single element in sorted array
class Solution(object):
    def singleNonDuplicate(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if(nums[len(nums)/2+1] != nums[len(nums)/2] and nums[len(nums)/2-1] != nums[len(nums)/2]):
            print(nums[len(nums)/2])
            return(nums[len(nums)/2])
        elif(nums[len(nums)/2-1] == nums[len(nums)/2]):
            self.singleNonDuplicate(nums[0:len(nums)/2])
        else:
            self.singleNonDuplicate(nums[len(nums)/2+1:])

You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element that appears only once.

The craziest thing is that I am printing the right answer but it says I am returning none. I don't know what's happening

Comments (1)