Maximum Path Sum
Coddy의 이진 트리 - 자료구조 시리즈 #3 코스 레슨 — 13개 중 13번째.
다음 챌린지들은 여러분이 구축한 BinaryTree를 사용합니다. 제공된 구현을 사용하여 문제를 해결하세요.
챌린지
쉬움BinaryTree를 나타내는 문자열을 받아 루트에서 리프(또는 임의의 자손)까지의 경로를 따라 있는 값들의 최대 합을 반환하는 getMaxPath라는 함수를 작성하세요.
직접 해보기
#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("%d\n", getMaxPath(s));
return 0;
}