All Tracks Data Structures Arrays 1-D Problem

Neutralisation of charges
Tag(s):

Easy

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
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

Notifications
View All Notifications

?