Skip to content

Instantly share code, notes, and snippets.

@prat0318
Created November 3, 2013 18:49
Show Gist options
  • Save prat0318/7293456 to your computer and use it in GitHub Desktop.
Save prat0318/7293456 to your computer and use it in GitHub Desktop.
def findOdd(arr):
index = 0
count = 1
last_char = arr[index]
while(index < len(arr)):
if(arr[index] != last_char):
break
count+=1
index+=1
count2 = 1
last_char2 = arr[index]
while(index < len(arr)):
if(arr[index] != last_char2):
break
count2+=1
index+=1
if count != count2:
count3 = 1
last_char3 = arr[index]
while(index < len(arr)):
if(arr[index] != last_char3):
break
count3+=1
index+=1
if count == count3:
return last_char2
else:
return last_char
else:
while(True):
count2 = 1
last_char = arr[index]
while(index < len(arr)):
if(arr[index] != last_char):
break
count2+=1
index+=1
if(count2 != count):
return last_char
if not(index < len(arr)):
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment