Compress the String
Practice
3.6 (15 votes)
Basic programming
Basics of implementation
Brute Force search
Easy
Implementation
String manipulation
Problem
69% Success 2949 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Given a string $$S$$ of lowercase english alphabets of length $$N$$. You need to compress the string with the following rules:
$$1$$. Convert the first letter to the uppercase
$$2$$. Convert the substring consisting of all the consonants to the length of this substring (e.g. abcde to a3e)
$$3$$. Remove the consecutive duplicate vowels (e.g. aaaeiia to aeia)

Note: The first letter will not follow the rules 2 and 3.

Input Format
The first line of the input contains the number $$T$$, the total number of the test cases.
The first line of each test case contains the number $$N$$, the length of the string $$S$$.
The second line of each test case contains the string $$S$$.

Output Format
For each test case print the compressed string according to the above-mentioned rules.

Constraints
$$1 \le T \le 10^3$$
$$1 \le N \le 10^5$$
Sum of $$N$$ over all test cases doesn't exceed $$10^6$$

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
26 votes
Tags:
ApprovedData StructuresEasyImplementationapproved
Points:30
24 votes
Tags:
AlgorithmsApprovedEasyOpen
Points:20
50 votes
Tags:
ApprovedBasic ProgrammingEasyHash MapsOpen