Update appNew update is available. Click here to update.

Remove Consecutive Duplicates

Last Updated: 25 Nov, 2020
Difficulty: Easy

PROBLEM STATEMENT

Try Problem

You are given a string ‘str’ of size ‘N’. Your task is to remove consecutive duplicates from this string recursively.

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.