There are 3 rules for a valid string:
- An empty string is valid
- You can add same character to a valid string X, and create another valid string yXy
- You can concatenate two valid strings X and Y, so XY will also be valid.
- Ex: vv, xbbx, bbccdd, xyffyxdd are all valid.
I tried using recursion. but could not complete all test cases. Good approaches or solutions will be helpful.