Given an integer N represented in the form of a string, remove consecutive repeated digits from it.
Example 1:
Input:
N = 1224
Output: 124
Explanation: Two consecutive occurrences of 
2 have been reduced to one.
Ã¢â¬â¹Example 2:
Input: 
N = 1242
Output: 1242
Explanation: No digit is repeating 
consecutively in N.
Your Task:
You don't need to read input or print anything. Your task is to complete the function modify() which takes the integer N as input and returns the modified integer by removing all the consecutive duplicate occurrences in N.
Expected Time Complexity: O(LogN).
Expected Auxiliary Space: O(1).
Constraints:
1<=N<=10^{18}

Difficulty: EASY
Tags: String algorithms

Data structures

Mathematics
Skill types: Data structures
Expected Time Complexity: O(LogN).
Expected Auxiliary Space: O(1).

Starter code:
#User function Template for python3

class Solution:
    def modify(self, N):
        #code here

Solutions:
class Solution:

	def modify(self, N):
		s = ''
		f = str(N)
		s = s + f[0]
		for i in range(1, len(f)):
			if f[i] != f[i - 1]:
				s = s + f[i]
		return s


class Solution:

	def modify(self, N):
		N = str(N)
		res = N[0]
		for i in range(1, len(N)):
			if N[i] != res[-1]:
				res += N[i]
		return res


class Solution:

	def modify(self, N):
		N = str(N)
		i = 1
		while i < len(N) - 1:
			if N[i] == N[i - 1]:
				N = N[:i] + N[i + 1:]
				i -= 1
			if N[i] == N[i + 1]:
				N = N[:i + 1] + N[i + 2:]
				i -= 1
			i += 1
		return N


class Solution:

	def modify(self, N):
		n = str(N)
		anas = '' + n[0]
		for i in n:
			if anas[-1] != i:
				anas += i
		return anas


class Solution:

	def modify(self, N):
		strN = str(N)
		i = 0
		while i < len(strN) - 1:
			if strN[i] == strN[i + 1]:
				strN = strN[:i] + strN[i + 1:]
			else:
				i += 1
		return strN


class Solution:

	def modify(self, n):
		ss = ''
		s = str(n)
		for i in s:
			if ss == '':
				ss += i
			elif i != ss[-1]:
				ss += i
		m = int(ss)
		return m


class Solution:

	def modify(self, N):
		h = str(N)
		c = []
		for i in range(len(h) - 1):
			if h[i] == h[i + 1]:
				pass
			else:
				c.append(h[i])
		if len(c) == 0:
			c.append(h[0])
		if len(c) > 0:
			if c[-1] == h[-1]:
				pass
			else:
				c.append(h[-1])
		return ''.join(c)


class Solution:

	def modify(self, N):
		k = str(N)
		s = ''
		for i in range(1, len(k)):
			if k[i - 1] == k[i]:
				continue
			else:
				s += k[i]
		return k[0] + s


class Solution:

	def modify(self, N):
		N = list(str(N))
		i = 1
		res = N[0]
		while i < len(N):
			if N[i] != N[i - 1]:
				res += N[i]
			i += 1
		res = int(res)
		return res


class Solution:

	def modify(self, N):
		n = str(N)
		ans = ''
		for i in range(len(n)):
			if n[i] not in ans:
				ans = ans + n[i]
			elif n[i - 1] == n[i]:
				pass
			else:
				ans = ans + n[i]
		return ans


class Solution:

	def modify(self, N):
		n = str(N)
		s = ''
		for i in range(len(n) - 1):
			if n[i] != n[i + 1]:
				s += n[i]
			else:
				i += 1
		return s + n[-1]


class Solution:

	def modify(self, N):
		ans = ''
		n = str(N)
		for i in range(len(n) - 1):
			if n[i] != n[i + 1]:
				ans += n[i]
		return ans + n[-1]


class Solution:

	def modify(self, N):
		N = str(N)
		st = [N[0]]
		for i in range(1, len(N)):
			if st[-1] != N[i]:
				st.append(N[i])
		st = ''.join(st)
		return int(st)


class Solution:

	def modify(self, N):
		N = str(N)
		k = list(N)
		for index in range(len(N) - 1):
			if N[index] == N[index + 1]:
				k.pop(index)
				k.insert(index, 'z')
		str1 = ''
		for index in k:
			if index != 'z':
				str1 += index
		return str1


class Solution:

	def modify(self, N):
		new = ''
		a = str(N)
		b = len(a)
		for i in range(b - 1):
			if a[i] != a[i + 1]:
				new = new + a[i]
		new = new + a[b - 1]
		return new


class Solution:

	def modify(self, N):
		N1 = str(N)
		str1 = ''
		for i in range(len(N1) - 1):
			if N1[i] != N1[i + 1]:
				str1 += N1[i]
			if i == len(N1) - 2:
				str1 += N1[i + 1]
		if len(N1) != len(str1):
			return str1
		else:
			return N1


class Solution:

	def modify(self, N):
		N = str(N)
		new_n = ''
		for i in range(len(N) - 1):
			if N[i] != N[i + 1]:
				new_n += N[i]
			else:
				continue
		return new_n + N[-1]


class Solution:

	def modify(self, N):
		N = str(N)
		N = list(N)
		i = 0
		while i < len(N) - 1:
			if N[i] == N[i + 1]:
				N.pop(i)
				i = -1
			i += 1
		return ''.join(N)


class Solution:

	def modify(self, N):
		out = ''
		N = str(N) + ' '
		for i in range(len(N) - 1):
			if N[i] != N[i + 1]:
				out += N[i]
		return int(out)


class Solution:

	def modify(self, n):
		s = ''
		n = str(n)
		l = len(n)
		for i in n:
			if s == '':
				s += i
			elif s[-1] != i:
				s += i
		return int(s)


class Solution:

	def modify(self, N):
		n = str(N)
		st = ''
		for i in range(len(n)):
			if i == 0:
				st = st + n[i]
			elif i > 0:
				if n[i] == n[i - 1]:
					continue
				else:
					st = st + n[i]
		return st


class Solution:

	def modify(self, N):
		l = ''
		for i in str(N):
			if l == '':
				l = i
			elif l[-1] != i:
				l = l + i
		return int(l)


class Solution:

	def modify(self, N):
		N = str(N)
		ans = ''
		l = len(N) - 1
		for i in range(l):
			if N[i] == N[i + 1]:
				i = i + 1
			else:
				ans = ans + N[i]
				i = i + 1
		ans = ans + N[l]
		return ans


from itertools import groupby

class Solution:

	def modify(self, N):
		k = ''
		a = list(groupby(str(N)))
		for (i, j) in a:
			k += i
		return k


class Solution:

	def modify(self, N):
		N = str(N)
		new_num = N[0]
		for char in N:
			if char != new_num[-1]:
				new_num = new_num + char
		return new_num


class Solution:

	def modify(self, N):
		digit = str(N)
		newDigit = digit[0]
		for i in range(1, len(digit)):
			if not digit[i] == digit[i - 1]:
				newDigit += digit[i]
		return newDigit


class Solution:

	def modify(self, N):
		s = str(N)
		temp = ''
		for i in range(len(s) - 1):
			if s[i] != s[i + 1]:
				temp += s[i]
		if temp == '':
			temp += s[-1]
		elif temp[-1] != s[-1]:
			temp += s[-1]
		return temp


class Solution:

	def modify(self, N):
		M = str(N)
		new_string = M[0]
		for i in M[1:]:
			if new_string[-1] != i:
				new_string += i
		return new_string


class Solution:

	def modify(self, N):
		ans = '-'
		for x in str(N):
			if x != ans[-1]:
				ans += x
		return int(ans[1:])


class Solution:

	def modify(self, N):
		a = str(N)
		l = ''
		for i in range(1, len(a)):
			if a[i - 1] == a[i]:
				continue
			else:
				l += a[i]
		return a[0] + l


class Solution:

	def modify(self, N):
		s = str(N)
		l = len(s)
		s1 = ''
		for i in range(l - 1):
			if s[i] != s[i + 1]:
				s1 = s1 + s[i]
		s1 = s1 + s[l - 1]
		return int(s1)


class Solution:

	def modify(self, N):
		num = str(N)
		string = ''
		for digit in range(1, len(num)):
			if num[digit - 1] == num[digit]:
				continue
			else:
				string += num[digit]
		return num[0] + string


class Solution:

	def modify(self, N):
		s = str(N)
		new_s = ''
		prev = ''
		for c in s:
			if len(new_s) == 0:
				new_s += c
				prev = c
			if c == prev:
				continue
			else:
				new_s += c
				prev = c
		return new_s


class Solution:

	def modify(self, N):
		n = int(N)
		ans = ''
		while n != 0:
			if len(ans) == 0 or ans[0] != str(n % 10):
				ans = str(n % 10) + ans
			n //= 10
		return ans


class Solution:

	def modify(self, N):
		N = str(N)
		i = 0
		a = ''
		while i < len(N):
			if i < len(N) - 1:
				if N[i] == N[i + 1]:
					i += 1
				else:
					a += N[i]
					i += 1
			elif i == len(N) - 1:
				a += N[len(N) - 1]
				i += 1
		return a


class Solution:

	def modify(self, N):
		(i, res, prev) = (0, 0, -1)
		while N > 0:
			r = N % 10
			if r != prev:
				res = res + r * 10 ** i
				i += 1
			prev = r
			N = N // 10
		return res


class Solution:

	def modify(self, N):
		N = str(N)
		new_N = ''
		x = ''
		for i in N:
			if x != i:
				new_N += i
			x = i
		return new_N


class Solution:

	def modify(self, u):
		N = []
		for i in str(u):
			N.append(i)
		ans = []
		for i in range(len(N) - 1):
			if N[i] != N[i + 1]:
				ans.append(N[i])
			else:
				continue
		if N[-1] == N[-2]:
			ans.append(N[-1])
		else:
			ans.append(N[-1])
		return ''.join(ans)


class Solution:

	def modify(self, N):
		ans = ''
		ans += str(N)[0]
		if len(str(N)) == 1:
			return N
		for i in range(1, len(str(N))):
			if str(N)[i] != str(N)[i - 1]:
				ans += str(N)[i]
		return int(ans)


class Solution:

	def modify(self, N):
		N = list(str(N))
		ans = [N[0]]
		for v in N:
			if v != ans[len(ans) - 1]:
				ans.append(v)
		ans = ''.join(ans)
		return ans


class Solution:

	def modify(self, N):
		z = ''
		last_seen = None
		res = []
		for x in str(N):
			if x != last_seen:
				res.append(x)
			last_seen = x
		for i in res:
			z = z + i
		return z


class Solution:

	def modify(self, N):
		a = str(N)
		i = 0
		j = 1
		a1 = ''
		while i < j and j < len(a):
			if a[i] != a[j]:
				a1 += a[i]
				i += 1
				j += 1
			else:
				i += 1
				j += 1
		a1 += a[-1]
		return a1


class Solution:

	def modify(self, N):
		l = [*str(N)]
		i = 0
		while True:
			if i + 1 == len(l):
				return ''.join(map(str, l))
			while l[i] == l[i + 1]:
				l.pop(i)
				if i + 1 == len(l):
					return ''.join(map(str, l))
			i += 1


class Solution:

	def modify(self, N):
		N = str(N)
		r = []
		for i in N:
			if r == []:
				r.append(i)
			elif r[-1] != i:
				r.append(i)
		return int(''.join(map(str, r)))


class Solution:

	def modify(self, s):
		s = str(s)
		s1 = ''
		for i in range(len(s) - 1):
			if s[i] == s[i + 1]:
				pass
			else:
				s1 = s1 + s[i]
		s1 = s1 + s[len(s) - 1]
		return int(s1)


class Solution:

	def modify(self, N):
		N = str(N)
		output = ''
		for i in range(len(N) - 1):
			if N[i] == N[i + 1]:
				continue
			output += N[i]
		output += N[-1]
		return output


class Solution:

	def modify(self, N):
		num = str(N)
		s = num[0]
		for i in range(1, len(num)):
			if num[i] == num[i - 1]:
				pass
			else:
				s += num[i]
		return int(s)


class Solution:

	def modify(self, N):
		n = ''
		string = str(N)
		for i in range(len(string) - 1):
			if string[i] != string[i + 1]:
				n += string[i + 1]
		return string[0] + n


class Solution:

	def modify(self, N):
		n = str(N)
		num = ''
		for i in range(1, len(n)):
			if n[i - 1] == n[i]:
				continue
			else:
				num += n[i]
		num_res = n[0] + num
		return int(num_res)


class Solution:

	def modify(self, N):
		result = ''
		stack = ''
		for i in str(N):
			if i != stack:
				result += i
				stack = i
		return result


class Solution:

	def modify(self, N):
		ans = ''
		s = str(N)
		y = len(s)
		for i in range(0, len(s) - 1):
			if s[i] == s[i + 1]:
				temp = ''
			else:
				ans = ans + s[i]
		return int(ans + s[y - 1])


class Solution:

	def modify(self, n):
		m = ''
		k = str(n)
		for i in range(len(k) - 1):
			if k[i] == k[i + 1]:
				continue
			else:
				m = m + k[i]
		m = m + k[-1]
		return m