๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Same Tree1

[์ž๋ฐ”] Leetcode 100 - Same Tree ์–ด์ฉŒ๋‹ค ๋ฉด์ ‘์ด ์žกํ˜€์„œ ๋ฐœ๋“ฑ์— ๋ถˆ๋–จ์–ด์ง„ ๋Š๋‚Œ์œผ๋กœ ๋ถ€๋žด๋ถ€๋žด ๋ฌธ์ œ ํ‘ธ๋Š”์ค‘ ใ…Ž ์นœ๊ตฌํ•œํ…Œ ๋ฆฌํŠธ์ฝ”๋“œ ์ถ”์ฒœ ๋ฐ›์•„์„œ Difficulty Easy๋‹จ๊ณ„๋ถ€ํ„ฐ ํ’€๊ณ  ์žˆ๋Š”๋ฐ, ์–ด๋ ต์ง€๋Š” ์•Š๋‹ค. ํ•˜์ง€๋งŒ ์ตœ์ ํ™”๋Š” ์ •๋ง ๋์ด ์—†๊ณ , ๋˜‘๋˜‘ํ•œ ์‚ฌ๋žŒ๋“ค์€ ์ด ์„ธ์ƒ์— ๋งŽ๋‹ค๋Š” ๊ฑธ ๊ณ„์†ํ•ด์„œ ๊นจ๋‹ซ๊ฒŒ ๋œ๋‹ค. TreeNode 2๊ฐœ๋ฅผ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋˜์ ธ์ฃผ๋ฉด ๊ทธ 2๊ฐœ์˜ TreeNode๋“ค์ด ๋™์ผํ•œ์ง€ ์•„๋‹ˆ์ง€๋ฅผ ํŒ๋ณ„ํ•˜๋Š” ๋ฉ”์†Œ๋“œ๋ฅผ ์งœ๋Š” ๋ฌธ์ œ๋‹ค. Class TreeNode๋Š” ์•„๋ž˜์ฒ˜๋Ÿผ ๊ตฌํ˜„๋˜์–ด ์žˆ๋‹ค๋Š” ๊ฐ€์ •ํ•˜์— ๋ฉ”์†Œ๋“œ ๋กœ์ง๋งŒ ์ฑ„์šฐ๋ฉด ๋œ๋‹ค. public class TreeNode { int val; TreeNode left; TreeNode right; TreeNode() {} TreeNode(int val) { this.val = val; } TreeNode(int va.. 2021. 2. 28.