diff --git a/code_study/Baekjoon/c/2263.c b/code_study/Baekjoon/c/2263.c new file mode 100644 index 0000000..37f89a6 --- /dev/null +++ b/code_study/Baekjoon/c/2263.c @@ -0,0 +1,35 @@ +#include + +int N, res_idx = 0; +int inOrderIdx[100001]; +int inOrder[100000]; +int postOrder[100000]; +int preOrder[100000]; + +void find(int in_start, int in_end, int post_start, int post_end) { + if(in_start > in_end || post_start > post_end) return; + + int root = postOrder[post_end]; + int root_idx = inOrderIdx[root]; + int left_size = root_idx - in_start; + + preOrder[res_idx++] = root; + find(in_start, root_idx - 1, post_start, post_start + left_size - 1); + find(root_idx + 1, in_end, post_start + left_size, post_end - 1); +} + +int main() { + scanf("%d",&N); + + for(int i=0; i