Skip to main content
6 of 6
removed the original version / added the new test cases
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

JavaScript (Node.js), 57 bytes

Expects an array of characters and returns a string.

s=>Buffer(s.flatMap(c=>c=="-"?a--:(a+=c=="+",[]),a=0))+""

Try it online!

Arnauld
  • 197.7k
  • 20
  • 179
  • 650