Problem title
Difficulty
Avg time to solve

Preorder Binary Tree
Easy
10 mins
Running Median
Hard
46 mins
Palindromic Substrings
Moderate
20 mins
Remove Consecutive Duplicates From String
Moderate
22 mins
Detect Cycle in an Undirected Graph
Moderate
32 mins
Moderate
22 mins
Spiral Matrix
Easy
15 mins
Maximum Size Rectangle Sub-matrix With All 1's
Hard
10 mins
Remove Consecutive Duplicates
Easy
--
Funny Divisors
Easy
15 mins
16

# Remove Consecutive Duplicates

Difficulty: EASY
Contributed By

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

#### Input Format:

``````The first line of input contains an integer 'T' representing the number of test cases.

The first line of each test case contains a single integer ‘N’ denoting the size of the given string.

The second line of each test case contains a string of size ‘N’.
``````

#### Output Format:

``````For each test case, print the new string that doesn’t have consecutive duplicates.

The output of each test case will be printed in a separate line.
``````

#### Constraints:

``````1 <= T <= 5
1 <= N <= 1000

Where ‘T’ is the number of test cases, ‘N’  is the length of the given string, and the given string contains only lowercase English letters.
``````

#### Note:

``````You do not need to print anything, it has already been taken care of. Just implement the given function.
``````

#### 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”
``````
Console