๐งธ ์๋ํฐ๋ฌธ์ ์ ๊ฐ์ ๋ฐฉ์์ผ๋ก ํ๋ฉด ๋๋ค.
์ฝ๋
const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().trim().split('\n');
const N = +input.shift();
for (let i = 0; i < N; i++) {
const leftStack = [];
const rigthStack = [];
const string = input[i].split("");
for (let j = 0; j < string.length; j++) {
if (string[j] === "<") {
if (leftStack.length) rigthStack.push(leftStack.pop());
} else if (string[j] === ">") {
if (rigthStack.length) leftStack.push(rigthStack.pop());
} else if (string[j] === "-") leftStack.pop();
else leftStack.push(string[j]);
}
rigthStack.reverse();
console.log([...leftStack, ...rigthStack].join(""));
}