Exceptionally odd Python
PROGRAM TO FIND THE NUMBER OCCURRING ODD NUMBER OF TIMES
OUTPUT:
5
def getOddOccurrence(arr): # Initialize result res = 0 # Traverse the array for element in arr: # XOR with the result res = res ^ element return res# Test arrayarr = [ 2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2]
5
Comments
Post a Comment