Handle Score
@Ibrahim Nash 6420
@blackshadows 6380
@mb1973 5646
@Quandray 5233
@akhayrutdinov 5111
@saiujwal13083 4716
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Complete Leaderboard
Remove repeated digits in a given number
Basic Accuracy: 61.39% Submissions: 44 Points: 1

Given an integer N represented in the form of a string, remove consecutive repeated digits from it.

Example 1:

N = 1224
Output: 124
Explanation: Two consecutive occurrences of 
2 have been reduced to one.

​Example 2:

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).



to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Remove repeated digits in a given number

Output Window