Reprint the given brace array so each word and brace sits on its own line with two-space indent per nesting level.
Easy3StackSimulationInterviewNo attempts yetTime limit1sMemory limit64 MBOne programming language defines an array like this.
{ marks the start of an array and a closing curly brace } marks its end.{}, {a,b,c}, and {abc,znj,{novi,niz},pozz}.The language raises no error when you leave out the spaces and newlines around the braces and the commas. You dislike how squished the values look, so you decide to rewrite the array by these rules.
} that ends an array, the indentation of the content shrinks by 2 spaces.The first line contains the array S described above. Here 1≤∣S∣≤1500, and S consists of lowercase English letters, curly braces, and commas only. S is always a correctly defined array.
Print the reshaped array.
Follow the input {a,b,{c,d},e,{}} step by step. At the start there is no indentation, so it is 0. After the first opening brace you print a newline and grow the indentation by 2 spaces.
Then you print the word a and the comma right after it, then a newline with the same indentation of 2 spaces. The word b follows the same procedure.
The third value is a new array. Call it X. It starts with an opening brace, so you print a newline and grow the indentation by 2 spaces. The indentation is now 4 spaces in total. With that indentation you print the words c and d, each on its own line. There is no comma after d because it is the last value of X.
Before printing the brace that ends X, you shrink the indentation by 2. After that brace you print the comma and a newline, then continue with the remaining values of the outer array.