All Tracks Data Structures Arrays 1-D Problem

Neutralisation of charges
/
No tags
Problem
Editorial
Analytics

In a parallel universe, there are not just two charges like positive and negative, but there are $$26$$ charges represented by  $$lower$$ english alphabets.

Charges have a property of killing each other or in other words neutralizing each other if they are of same charge and next to each other.

You are given a string $$s$$ where each $$s_i$$ represents a charge, where $$0 \le i \le |s|-1 $$.

You need to output $$size$$ of final string followed by string after which no neutralizing is possible.

SAMPLE INPUT
12
aaacccbbcccd
SAMPLE OUTPUT
2
ad
Explanation
aaacccbbcccd -> accd -> ad
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

Initializing Code Editor...
Notifications
View All Notifications

?