Symmetric Tree
Coddy의 이진 트리 - 자료구조 시리즈 #3 코스 레슨 — 13개 중 12번째.
다음 챌린지들은 여러분이 구축한 BinaryTree를 사용합니다. 제공된 구현을 사용하여 문제를 해결하세요.
챌린지
쉬움BinaryTree를 나타내는 문자열을 인자로 받아, 해당 트리가 대칭(루트를 중심으로 거울 이미지)이면 true를, 그렇지 않으면 false를 반환하는 isSymmetric이라는 이름의 함수를 작성하세요.
직접 해보기
#include <stdio.h>
#include <string.h>
#include "solution.h"
int main() {
char s[4096];
if (!fgets(s, sizeof(s), stdin)) s[0] = '\0';
s[strcspn(s, "\r\n")] = '\0';
printf("%s\n", isSymmetric(s) ? "true" : "false");
return 0;
}