From 9a209363fec4824f99954e74af08904fb2ef94b2 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Thu, 2 Oct 2025 15:55:03 +0900 Subject: [PATCH] 20251001 baekjoon --- code_study/Baekjoon/c/9935.c | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 code_study/Baekjoon/c/9935.c diff --git a/code_study/Baekjoon/c/9935.c b/code_study/Baekjoon/c/9935.c new file mode 100644 index 0000000..4573866 --- /dev/null +++ b/code_study/Baekjoon/c/9935.c @@ -0,0 +1,47 @@ +#include +#include +#include + +bool isBoom(char* stack, char* boom, int top, int lenB); +void printStack(char* stack, int top); + +int main() { + char str[1000001]; + char stack[1000001]; + char boom[36]; + int top = -1; + + scanf("%s",str); + int len = strlen(str); + scanf("%s",boom); + int lenB = strlen(boom); + + for (int i = 0; i < len; i++) { + stack[++top] = str[i]; + if (top + 1 >= lenB && isBoom(stack, boom, top, lenB)) { + top -= lenB; + } + } + + printStack(stack, top); + + return 0; +} + +bool isBoom(char* stack, char* boom, int top, int lenB) { + for (int i=0; i