{"id":28138,"date":"2024-10-27T15:32:02","date_gmt":"2024-10-27T15:32:02","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=28138"},"modified":"2024-11-26T07:08:27","modified_gmt":"2024-11-26T07:08:27","slug":"%ec%8a%a4%ec%9c%84%ed%94%84%ed%8a%b8-%ec%bd%94%eb%94%a9%ed%85%8c%ec%8a%a4%ed%8a%b8-%ea%b0%95%ec%a2%8c-%ea%b9%8a%ec%9d%b4-%ec%9a%b0%ec%84%a0-%ed%83%90%ec%83%89","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/28138\/","title":{"rendered":"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9"},"content":{"rendered":"<p><body><\/p>\n<header>\n<p>\ubcf8 \uac15\uc88c\uc5d0\uc11c\ub294 \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9(DFS, Depth-First Search) \uc54c\uace0\ub9ac\uc998\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc54c\uace0\ub9ac\uc998 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\ub294 \ubc29\ubc95\uc744 \uc124\uba85\ud569\ub2c8\ub2e4. \uc774 \uae00\uc5d0\uc11c\ub294 \uc2e4\uc81c \uc54c\uace0\ub9ac\uc998 \ubb38\uc81c\ub97c \ub2e4\ub8e8\uace0, \uadf8 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud55c \uacfc\uc815\uacfc \ucf54\ub4dc\ub97c \uc790\uc138\ud788 \uc124\uba85\ud558\uaca0\uc2b5\ub2c8\ub2e4.<\/p>\n<\/header>\n<section>\n<h2>\ubb38\uc81c \uc124\uba85<\/h2>\n<p>\uc8fc\uc5b4\uc9c4 \uc774\uc9c4 \ud2b8\ub9ac\uc5d0\uc11c \ubaa8\ub4e0 \uacbd\ub85c\uc758 \ud569\uc744 \uad6c\ud558\uae30\ub97c \uc6d0\ud569\ub2c8\ub2e4. \uac01 \uacbd\ub85c\ub294 \ub8e8\ud2b8\uc5d0\uc11c \ub9ac\ud504 \ub178\ub4dc\uae4c\uc9c0\uc758 \uacbd\ub85c\uc785\ub2c8\ub2e4. \uc774\uc9c4 \ud2b8\ub9ac\ub294 \ub2e4\uc74c\uacfc \uac19\uc740 \ud615\ud0dc\ub85c \uc8fc\uc5b4\uc9d1\ub2c8\ub2e4:<\/p>\n<pre>\n        class TreeNode {\n            var val: Int\n            var left: TreeNode?\n            var right: TreeNode?\n\n            init(_ val: Int) {\n                self.val = val\n                self.left = nil\n                self.right = nil\n            }\n        }\n        <\/pre>\n<p>\uc5ec\uae30\uc11c \uac01 \ub178\ub4dc\ub294 \uac12(val)\uc744 \uac00\uc9c0\uace0 \uc788\uc73c\uba70, \uc67c\ucabd \uc790\uc2dd(left)\uacfc \uc624\ub978\ucabd \uc790\uc2dd(right)\uc73c\ub85c \uc774\uc5b4\uc838 \uc788\uc2b5\ub2c8\ub2e4. \ub9cc\uc57d \ub2e4\uc74c\uacfc \uac19\uc740 \uc774\uc9c4 \ud2b8\ub9ac\uac00 \uc8fc\uc5b4\uc9c4\ub2e4\uba74:<\/p>\n<pre>\n               1\n              \/ \\\n             2   3\n            \/ \\\n           4   5\n        <\/pre>\n<p>\ub8e8\ud2b8 \ub178\ub4dc 1\uc5d0\uc11c \uc2dc\uc791\ud558\uc5ec \ub9ac\ud504 \ub178\ub4dc 4\uc640 5\uae4c\uc9c0\uc758 \uacbd\ub85c\uc758 \ud569\uc740 7(1+2+4)\uacfc 8(1+2+5)\uc774 \ub418\ubbc0\ub85c, \ucd5c\uc885 \ub2f5\uc740 15\uac00 \ub429\ub2c8\ub2e4.<\/p>\n<\/section>\n<section>\n<h2>\ubb38\uc81c \uc811\uadfc \ubc29\ubc95<\/h2>\n<p>\uc774 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud574 DFS \uc54c\uace0\ub9ac\uc998\uc744 \uc0ac\uc6a9\ud560 \uac83\uc785\ub2c8\ub2e4. DFS\ub294 \ud2b9\uc815 \ub178\ub4dc\uc5d0\uc11c \uc2dc\uc791\ud558\uc5ec \uac00\ub2a5\ud55c \ud55c \uae4a\uc219\uc774 \ub178\ub4dc\ub97c \ud0d0\uc0c9\ud558\uace0, \ub354 \uc774\uc0c1 \uac08 \uc218 \uc5c6\uac8c \ub418\uba74 \ub3cc\uc544\uc624\ub294 \ubc29\uc2dd\uc73c\ub85c \uc791\ub3d9\ud569\ub2c8\ub2e4. \uc774 \uacbd\uc6b0, \uc6b0\ub9ac\ub294 \uac01 \uacbd\ub85c\uc758 \ub204\uc801 \ud569\uc744 \uacc4\uc0b0\ud558\uba74\uc11c \ub9ac\ud504 \ub178\ub4dc\uc5d0 \ub3c4\ub2ec\ud588\uc744 \ub54c \uadf8 \ud569\uc744 \uae30\ub85d\ud560 \uac83\uc785\ub2c8\ub2e4.<\/p>\n<p>\ubb38\uc81c\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud55c \ub2e8\uacc4\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4:<\/p>\n<ol>\n<li>\ub8e8\ud2b8 \ub178\ub4dc\uc5d0\uc11c \uc2dc\uc791\ud558\uc5ec DFS\ub97c \uc218\ud589\ud569\ub2c8\ub2e4.<\/li>\n<li>\ud604\uc7ac \ub178\ub4dc\uc758 \uac12(val)\uc744 \ub204\uc801 \ud569\uc5d0 \ub354\ud569\ub2c8\ub2e4.<\/li>\n<li>\ud604\uc7ac \ub178\ub4dc\uac00 \ub9ac\ud504 \ub178\ub4dc\uc778 \uacbd\uc6b0, \ub204\uc801 \ud569\uacc4\ub97c \uacb0\uacfc\uc5d0 \ucd94\uac00\ud569\ub2c8\ub2e4.<\/li>\n<li>\ub9ac\ud504 \ub178\ub4dc\uac00 \uc544\ub2cc \uacbd\uc6b0, \uc67c\ucabd \uc790\uc2dd\uacfc \uc624\ub978\ucabd \uc790\uc2dd\uc73c\ub85c \ub098\uc544\uac00 DFS\ub97c \uc7ac\uadc0\uc801\uc73c\ub85c \ud638\ucd9c\ud569\ub2c8\ub2e4.<\/li>\n<li>\ubaa8\ub4e0 \uacbd\ub85c\uc5d0 \ub300\ud574 \uc704\uc758 \uacfc\uc815\uc744 \ubc18\ubcf5\ud558\uc5ec \ub204\uc801 \ud569\uc744 \uad6c\ud569\ub2c8\ub2e4.<\/li>\n<\/ol>\n<\/section>\n<section>\n<h2>\uc2a4\uc704\ud504\ud2b8 \ucf54\ub4dc \uad6c\ud604<\/h2>\n<p>\uc774\uc81c \uc2a4\uc704\ud504\ud2b8\ub97c \uc0ac\uc6a9\ud558\uc5ec \uc704\uc758 \uc54c\uace0\ub9ac\uc998\uc744 \ucf54\ub4dc\ub85c \uad6c\ud604\ud574 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4.<\/p>\n<pre>\n        class TreeNode {\n            var val: Int\n            var left: TreeNode?\n            var right: TreeNode?\n\n            init(_ val: Int) {\n                self.val = val\n                self.left = nil\n                self.right = nil\n            }\n        }\n\n        class Solution {\n            func sumNumbers(_ root: TreeNode?) -&gt; Int {\n                return dfs(root, 0)\n            }\n\n            private func dfs(_ node: TreeNode?, _ currentSum: Int) -&gt; Int {\n                guard let node = node else { return 0 }\n                let newSum = currentSum * 10 + node.val\n\n                if node.left == nil &amp;&amp; node.right == nil {\n                    return newSum\n                }\n\n                return dfs(node.left, newSum) + dfs(node.right, newSum)\n            }\n        }\n        <\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\ub294 \uc7ac\uadc0\uc801\uc73c\ub85c DFS\ub97c \uc218\ud589\ud558\uc5ec \uacbd\ub85c\uc758 \ud569\uacc4\ub97c \uacc4\uc0b0\ud569\ub2c8\ub2e4. <code>sumNumbers<\/code> \ud568\uc218\ub294 \ub8e8\ud2b8 \ub178\ub4dc\ub97c \uc778\uc218\ub85c \ubc1b\uc73c\uba70, <code>dfs<\/code> \ud568\uc218\ub294 \ud604\uc7ac \ub178\ub4dc\uc640 \ub204\uc801 \ud569\uc744 \uc778\uc218\ub85c \ubc1b\uc544\uc11c \ucd5c\uc885 \ud569\uc744 \ubc18\ud658\ud569\ub2c8\ub2e4. \uacfc\uc815\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4:<\/p>\n<ol>\n<li><code>sumNumbers<\/code> \ud568\uc218\uac00 \ud638\ucd9c\ub418\uba74, \ud604\uc7ac \ub204\uc801 \ud569 0\uc73c\ub85c DFS\ub97c \uc2dc\uc791\ud569\ub2c8\ub2e4.<\/li>\n<li>\uac01 \ub178\ub4dc\uc5d0 \ub300\ud574, \ud604\uc7ac \ud569\uc744 10\ubc30\ud558\uace0 \ub178\ub4dc \uac12\uc744 \ub354\ud558\uc5ec \uc0c8\ub85c\uc6b4 \ud569\uc744 \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/li>\n<li>\ub9ac\ud504 \ub178\ub4dc\uc5d0 \ub3c4\ub2ec\ud558\uba74 \ud574\ub2f9 \ud569\uc744 \ubc18\ud658\ud558\uace0, \uc67c\ucabd\uacfc \uc624\ub978\ucabd \uc790\uc2dd\uc758 \ud569\uc744 \ub354\ud55c \ud6c4 \ucd5c\uc885 \uacb0\uacfc\ub97c \ubc18\ud658\ud569\ub2c8\ub2e4.<\/li>\n<\/ol>\n<\/section>\n<section>\n<h2>\ud14c\uc2a4\ud2b8 \ucf00\uc774\uc2a4<\/h2>\n<p>\ucf54\ub4dc\uac00 \uc62c\ubc14\ub974\uac8c \uc791\ub3d9\ud558\ub294\uc9c0 \ud655\uc778\ud558\uae30 \uc704\ud574 \uba87 \uac00\uc9c0 \ud14c\uc2a4\ud2b8 \ucf00\uc774\uc2a4\ub97c \uc0dd\uc131\ud574\ubcf4\uaca0\uc2b5\ub2c8\ub2e4. \ub2e4\uc74c\uc740 \ub2e4\uc591\ud55c \uc774\uc9c4 \ud2b8\ub9ac \uad6c\uc870\uc5d0 \ub300\ud55c \uc608\uc785\ub2c8\ub2e4.<\/p>\n<pre>\n        let root = TreeNode(1)\n        root.left = TreeNode(2)\n        root.right = TreeNode(3)\n        root.left!.left = TreeNode(4)\n        root.left!.right = TreeNode(5)\n\n        let solution = Solution()\n        print(solution.sumNumbers(root)) \/\/ \ucd9c\ub825\uac12: 15\n        <\/pre>\n<p>\uc704\uc758 \ud14c\uc2a4\ud2b8 \ucf00\uc774\uc2a4\uc5d0\uc11c\ub294 1\uc5d0\uc11c \uc2dc\uc791\ud558\uc5ec 2\ub97c \uac70\uccd0 4\uc640 5\uc5d0 \ub3c4\ub2ec\ud558\ub294 \ubaa8\ub4e0 \uacbd\ub85c\uc758 \ud569\uc744 \uacc4\uc0b0\ud569\ub2c8\ub2e4. \uadf8 \uacb0\uacfc, 1-2-4\uc640 1-2-5\uc758 \ud569\uc774 \ub354\ud574\uc838 15\uac00 \ub429\ub2c8\ub2e4.<\/p>\n<\/section>\n<section>\n<h2>\uc131\uacfc \ubc0f \ucd5c\uc801\ud654<\/h2>\n<p>\uc774 \ubb38\uc81c\uc5d0\uc11c\ub294 DFS \ubc29\ubc95\uc744 \uc0ac\uc6a9\ud558\uc5ec O(N) \uc2dc\uac04 \ubcf5\uc7a1\ub3c4\ub97c \uac00\uc9d1\ub2c8\ub2e4. \uc5ec\uae30\uc11c N\uc740 \ub178\ub4dc\uc758 \uc218\uc785\ub2c8\ub2e4. \uacf5\uac04 \ubcf5\uc7a1\ub3c4\ub294 O(H)\ub85c, H\ub294 \ud2b8\ub9ac\uc758 \ub192\uc774\uc785\ub2c8\ub2e4. DFS\ub294 \uc2a4\ud0dd\uc744 \uc0ac\uc6a9\ud558\uae30 \ub54c\ubb38\uc5d0 \ucd5c\uc545\uc758 \uacbd\uc6b0\uc5d0\ub294 \ubaa8\ub4e0 \ub178\ub4dc\ub97c \ubc29\ubb38\ud574\uc57c \ud558\ubbc0\ub85c \ub192\uc774\uc5d0 \ube44\ub840\ud558\ub294 \uba54\ubaa8\ub9ac\ub97c \uc0ac\uc6a9\ud558\uac8c \ub429\ub2c8\ub2e4.<\/p>\n<p>\uc774 \uc678\uc5d0\ub3c4 BFS(Breadth-First Search) \ubc29\ubc95\uc744 \uc0ac\uc6a9\ud574 \ubb38\uc81c\ub97c \ud480 \uc218\ub3c4 \uc788\uc9c0\ub9cc, \ub9ac\ud504 \ub178\ub4dc\uae4c\uc9c0\uc758 \uacbd\ub85c\uc758 \ud569\uc744 \uad6c\ud558\ub294 \ubb38\uc81c\uc5d0\uc11c\ub294 DFS\uac00 \ub354 \uc9c1\uad00\uc801\uc774\uace0 \ud6a8\uc728\uc801\uc785\ub2c8\ub2e4.<\/p>\n<\/section>\n<section>\n<h2>\uacb0\ub860<\/h2>\n<p>\uc774\ubc88 \uac15\uc88c\uc5d0\uc11c\ub294 \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9\uc744 \ud1b5\ud574 \uc774\uc9c4 \ud2b8\ub9ac\uc5d0\uc11c \ub9ac\ud504 \ub178\ub4dc\uae4c\uc9c0\uc758 \uacbd\ub85c \ud569\uc744 \uad6c\ud558\ub294 \ubb38\uc81c\ub97c \ub2e4\ub918\uc2b5\ub2c8\ub2e4. DFS \uc54c\uace0\ub9ac\uc998\uc758 \uac1c\ub150\uc744 \uc774\ud574\ud558\uace0, \uc774\ub97c \uc2a4\uc704\ud504\ud2b8\ub85c \uad6c\ud604\ud574 \ubcf4\uc558\uc2b5\ub2c8\ub2e4. \uc774\ub7f0 \ubb38\uc81c\ub4e4\uc740 \ub9ce\uc740 \ucf54\ub529 \ud14c\uc2a4\ud2b8\uc5d0\uc11c \uc790\uc8fc \ucd9c\uc81c\ub418\ubbc0\ub85c, \ub2e4\uc591\ud55c \ubcc0\ud615 \ubb38\uc81c\ub97c \ud1b5\ud574 \ub354 \ub9ce\uc740 \uc5f0\uc2b5\uc744 \ud574\ubcf4\uc2dc\uae38 \uad8c\uc7a5\ud569\ub2c8\ub2e4.<\/p>\n<p>\uc774\uc81c \uae30\ucd08\uc801\uc778 DFS\ub97c \ub2e4\ub8e8\uc5c8\uc73c\ub2c8, \ub354 \ubcf5\uc7a1\ud55c \ubb38\uc81c\uc5d0 \ub300\ud574 \ub3c4\uc804\ud574 \ubcf4\uc138\uc694. \uc608\ub97c \ub4e4\uc5b4, \uadf8\ub798\ud504 \ud0d0\uc0c9, \uc5f0\uacb0 \uc694\uc18c \ucc3e\uae30, \ucd5c\ub2e8 \uacbd\ub85c \ubb38\uc81c \ub4f1\uc73c\ub85c \ubc94\uc704\ub97c \ud655\uc7a5\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc5f0\uc2b5\uc744 \ud1b5\ud574 \ub354\uc6b1 \ub2a5\uc219\ud55c \ucf54\ub529 \ub2a5\ub825\uc744 \uac16\ucd94\uc2dc\uae38 \ubc14\ub78d\ub2c8\ub2e4.<\/p>\n<\/section>\n<footer>\n<p>\uc774 \uae00\uc774 \uc5ec\ub7ec\ubd84\uc758 \ucf54\ub4dc \ud14c\uc2a4\ud2b8 \uc900\ube44\uc5d0 \ub3c4\uc6c0\uc774 \ub418\uc5c8\uae30\ub97c \ubc14\ub78d\ub2c8\ub2e4. \uc9c8\ubb38\uc774\ub098 \ucd94\uac00\uc801\uc778 \ub313\uae00\uc774 \uc788\ub2e4\uba74 \uc544\ub798\uc5d0 \ub0a8\uaca8\uc8fc\uc138\uc694.<\/p>\n<\/footer>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ubcf8 \uac15\uc88c\uc5d0\uc11c\ub294 \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9(DFS, Depth-First Search) \uc54c\uace0\ub9ac\uc998\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc54c\uace0\ub9ac\uc998 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\ub294 \ubc29\ubc95\uc744 \uc124\uba85\ud569\ub2c8\ub2e4. \uc774 \uae00\uc5d0\uc11c\ub294 \uc2e4\uc81c \uc54c\uace0\ub9ac\uc998 \ubb38\uc81c\ub97c \ub2e4\ub8e8\uace0, \uadf8 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud55c \uacfc\uc815\uacfc \ucf54\ub4dc\ub97c \uc790\uc138\ud788 \uc124\uba85\ud558\uaca0\uc2b5\ub2c8\ub2e4. \ubb38\uc81c \uc124\uba85 \uc8fc\uc5b4\uc9c4 \uc774\uc9c4 \ud2b8\ub9ac\uc5d0\uc11c \ubaa8\ub4e0 \uacbd\ub85c\uc758 \ud569\uc744 \uad6c\ud558\uae30\ub97c \uc6d0\ud569\ub2c8\ub2e4. \uac01 \uacbd\ub85c\ub294 \ub8e8\ud2b8\uc5d0\uc11c \ub9ac\ud504 \ub178\ub4dc\uae4c\uc9c0\uc758 \uacbd\ub85c\uc785\ub2c8\ub2e4. \uc774\uc9c4 \ud2b8\ub9ac\ub294 \ub2e4\uc74c\uacfc \uac19\uc740 \ud615\ud0dc\ub85c \uc8fc\uc5b4\uc9d1\ub2c8\ub2e4: class TreeNode { var val: &hellip; <a href=\"https:\/\/atmokpo.com\/w\/28138\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[27],"tags":[],"class_list":["post-28138","post","type-post","status-publish","format-standard","hentry","category-27"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/28138\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"\ubcf8 \uac15\uc88c\uc5d0\uc11c\ub294 \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9(DFS, Depth-First Search) \uc54c\uace0\ub9ac\uc998\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc54c\uace0\ub9ac\uc998 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\ub294 \ubc29\ubc95\uc744 \uc124\uba85\ud569\ub2c8\ub2e4. \uc774 \uae00\uc5d0\uc11c\ub294 \uc2e4\uc81c \uc54c\uace0\ub9ac\uc998 \ubb38\uc81c\ub97c \ub2e4\ub8e8\uace0, \uadf8 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud55c \uacfc\uc815\uacfc \ucf54\ub4dc\ub97c \uc790\uc138\ud788 \uc124\uba85\ud558\uaca0\uc2b5\ub2c8\ub2e4. \ubb38\uc81c \uc124\uba85 \uc8fc\uc5b4\uc9c4 \uc774\uc9c4 \ud2b8\ub9ac\uc5d0\uc11c \ubaa8\ub4e0 \uacbd\ub85c\uc758 \ud569\uc744 \uad6c\ud558\uae30\ub97c \uc6d0\ud569\ub2c8\ub2e4. \uac01 \uacbd\ub85c\ub294 \ub8e8\ud2b8\uc5d0\uc11c \ub9ac\ud504 \ub178\ub4dc\uae4c\uc9c0\uc758 \uacbd\ub85c\uc785\ub2c8\ub2e4. \uc774\uc9c4 \ud2b8\ub9ac\ub294 \ub2e4\uc74c\uacfc \uac19\uc740 \ud615\ud0dc\ub85c \uc8fc\uc5b4\uc9d1\ub2c8\ub2e4: class TreeNode { var val: &hellip; \ub354 \ubcf4\uae30 &quot;\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/28138\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-10-27T15:32:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-26T07:08:27+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/28138\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/28138\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9\",\"datePublished\":\"2024-10-27T15:32:02+00:00\",\"dateModified\":\"2024-11-26T07:08:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/28138\/\"},\"wordCount\":31,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/28138\/\",\"url\":\"https:\/\/atmokpo.com\/w\/28138\/\",\"name\":\"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-10-27T15:32:02+00:00\",\"dateModified\":\"2024-11-26T07:08:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/28138\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/28138\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/28138\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/28138\/","og_locale":"ko_KR","og_type":"article","og_title":"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"\ubcf8 \uac15\uc88c\uc5d0\uc11c\ub294 \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9(DFS, Depth-First Search) \uc54c\uace0\ub9ac\uc998\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc54c\uace0\ub9ac\uc998 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\ub294 \ubc29\ubc95\uc744 \uc124\uba85\ud569\ub2c8\ub2e4. \uc774 \uae00\uc5d0\uc11c\ub294 \uc2e4\uc81c \uc54c\uace0\ub9ac\uc998 \ubb38\uc81c\ub97c \ub2e4\ub8e8\uace0, \uadf8 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud55c \uacfc\uc815\uacfc \ucf54\ub4dc\ub97c \uc790\uc138\ud788 \uc124\uba85\ud558\uaca0\uc2b5\ub2c8\ub2e4. \ubb38\uc81c \uc124\uba85 \uc8fc\uc5b4\uc9c4 \uc774\uc9c4 \ud2b8\ub9ac\uc5d0\uc11c \ubaa8\ub4e0 \uacbd\ub85c\uc758 \ud569\uc744 \uad6c\ud558\uae30\ub97c \uc6d0\ud569\ub2c8\ub2e4. \uac01 \uacbd\ub85c\ub294 \ub8e8\ud2b8\uc5d0\uc11c \ub9ac\ud504 \ub178\ub4dc\uae4c\uc9c0\uc758 \uacbd\ub85c\uc785\ub2c8\ub2e4. \uc774\uc9c4 \ud2b8\ub9ac\ub294 \ub2e4\uc74c\uacfc \uac19\uc740 \ud615\ud0dc\ub85c \uc8fc\uc5b4\uc9d1\ub2c8\ub2e4: class TreeNode { var val: &hellip; \ub354 \ubcf4\uae30 \"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9\"","og_url":"https:\/\/atmokpo.com\/w\/28138\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-10-27T15:32:02+00:00","article_modified_time":"2024-11-26T07:08:27+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"1\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/28138\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/28138\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9","datePublished":"2024-10-27T15:32:02+00:00","dateModified":"2024-11-26T07:08:27+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/28138\/"},"wordCount":31,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/28138\/","url":"https:\/\/atmokpo.com\/w\/28138\/","name":"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-10-27T15:32:02+00:00","dateModified":"2024-11-26T07:08:27+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/28138\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/28138\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/28138\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"\uc2a4\uc704\ud504\ud2b8 \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uae4a\uc774 \uc6b0\uc120 \ud0d0\uc0c9"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/28138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=28138"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/28138\/revisions"}],"predecessor-version":[{"id":28139,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/28138\/revisions\/28139"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=28138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=28138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=28138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}