Easy · Streams & I/O
Add Spaces Around Parentheses in a String
Given a string s, return it with every '(' and ')' set apart from its neighbours by exactly one ordinary space, every run of ordinary spaces reduced to one, and no ordinary space at either end; preserve other whitespace characters unchanged.
Examples
Example 1
{
"s": "(a(b)c)"
}Output: "( a ( b ) c )"
Example 2
{
"s": "hello(world)"
}Output: "hello ( world )"
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.