Close
Topic list
Remove Consecutive Duplicates
EASY
Strings
Topics (Covered in this problem)
Problem solved
Skill meter
Strings
-
-
Other topics
Problem solved
Skill meter
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Remove Consecutive Duplicates

Contributed by
Sobhagya Singh
Easy
0/40
Share

## Problem Statement

#### For example:

``````If the input string is ‘str’ = ”aazbbby”, then your output will be “azby”.
Note that we are just removing adjacent duplicates.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )

#### Sample Input 1:

``````2
7
aazbbby
6
aabbcb
``````

#### Sample Output 1:

``````azby
abcb
``````

#### Explanation of Sample Input 1:

``````Test Case 1:

Given ‘str' = ”aazbbby”
After removing adjacent duplicates string will be “azby”

Test Case 2:

Given ‘str’ = “aabbcb”
After removing adjacent duplicates string will be “abcb”
``````

#### Sample Input 2:

``````2
5
abcde
5
aaaaa
``````

#### Sample Output 2:

``````abcde
a
``````

#### Explanation of Sample Input 2:

``````Test Case 1:

Given ‘str' = ”abcde”
There are no duplicates in the input string so the final string will be “abcde”

Test Case 2:

Given ‘str’ = “aaaaa”
After removing adjacent duplicates string will be “a”
``````
Auto
Console