Handle Score
@Ibrahim Nash 6420
@blackshadows 6380
@mb1973 5704
@Quandray 5245
@akhayrutdinov 5111
@saiujwal13083 5046
@sanjay05 3762
@kirtidee18 3673
@mantu_singh 3530
@marius_valentin_dragoi 3523
@sushant_a 3459
Complete Leaderboard
Remove repeated digits in a given number
Basic Accuracy: 70.73% Submissions: 82 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