We are given an integer which can be large as 10 to the power of 18 and we have to replace all consecutive repeating digits with zero.
I have tried by converting the integer to string but it takes a lot of time in doing type conversion from integer to string. Is there any way to do the function without converting it to string. My code by converting the integer to string -:
def replace(l):
l1 = str(l)
s = l1[0]
temp = s[0]
for i in range(1, len(l1)):
if l1[i] == temp:
s += '0'
else:
s += l1[i]
temp = l1[i]
l = int(s)
return l
Example-: Let integer be 1222433444
Expected output -: 1200430400