I found a problem statement over the internet, was trying to solve it in ruby.
Input and output are self explanatory.
Eg. 1, Input : 2[abc]3[ab]c<
2[abc]3[ab]c