๐ŸŽฒ ๋ฐฑ์ค€ 12904๋ฒˆ A์™€ B

Jeongeunยท2023๋…„ 10์›” 15์ผ
0

๋ฐฑ์ค€

๋ชฉ๋ก ๋ณด๊ธฐ
126/186

๋ฐฑ์ค€12904๋ฒˆ

๐Ÿ’ก T๊ฐ€ S๊ฐ€ ๋  ์ˆ˜ ์žˆ๋Š”์ง€ ์ƒ๊ฐํ•˜๋ฉด ์‰ฝ๊ฒŒ ํ’€ ์ˆ˜ ์žˆ๋‹ค. ์ด ๋ฐฉ๋ฒ•์„ ์ƒ๊ฐํ•˜๋Š”๊ฒŒ ์‹œ๊ฐ„์ด ์ข€ ๊ฑธ๋ ธ๋‹ค.๐Ÿ˜…

const fs = require('fs'); 
const [S, T] = fs.readFileSync('/dev/stdin').toString().trim().split('\n');

let temp = T.split("");

while (S.length !== temp.length) {
  if (temp[temp.length - 1] === "A") {
    temp.pop();
  } else {
    temp.pop();
    temp = temp.reverse();
  }
}

if (S === temp.join("")) {
  console.log(1);
} else {
  console.log(0);
}

0๊ฐœ์˜ ๋Œ“๊ธ€