Published: 21 May 2018 › Updated: 21 May 2018![[Leetcode] 100.same-tree](https://i.ecency.com/p/7ohP4GDMGPrUMp8dW6yuJTR9MKNu8P8DCXDU9qmmhcFMiZyoeysygN2Pmqy42dpqfVeB2bVZBGek4aPYoo5mUkar8SaBsH9Lu389?format=match&mode=fit&height=377)
[Leetcode] 100.same-tree
문제
- [100] Same Tree
- Easy (47.95%)
- Total Accepted: 270.6K
- Total Submissions: 564.2K
- https://leetcode.com/problems/same-tree/description/
- 두 개의 트리가 있을 때, 같은 트리인지 확인하라.
풀이 과정
같은 트리인지 어떻게 확인하지?
- 트리 구조가 같은지 체크한다.
- 두 개의 트리에서 특정 노드의 value가 같은지 체크한다.
탐색 순서는?
- preorder로 하자.
- 재귀적으로 가자.
Submission Fail
- []\n[] --> NULL인 경우를 신경 안썼다. --> 런타임 에러 발생
- [1]\n[] --> 마찬가지이다. -->런타임 에러 발생
- [1,2,1]\n[1,1,2] --> 트리 구조만 같은지 체크했었다. --> 에러
일주일에 최소 2개 이상 꾸준히 풀어보고 싶어요!
Leave [Leetcode] 100.same-tree to:
Read more #jjangjjangman posts
Best Posts From Jacob
We have not curated any of jacobyu's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.