๋ฌธ์
ํ์ด ๊ณผ์
์ด์ง ๊ฒ์ ํธ๋ฆฌ์ ์ค์ ์ํ
๋ฅผ ๊ตฌํํ๋ ๋ฌธ์ ์
๋๋ค. ์ฌ๊ท ํธ์ถ
์ ์ด์ฉํด์ ์ผ์ชฝ ์๋ธํธ๋ฆฌ, ์๋ธ ๋ฃจํธ, ์ค๋ฅธ์ชฝ ์๋ธํธ๋ฆฌ
์์๋ก ๋ฐฉ๋ฌธํด์ฃผ๋ฉด ๋ฉ๋๋ค.
์ฝ๋
/**
* Definition for a binary tree node.
* function TreeNode(val, left, right) {
* this.val = (val===undefined ? 0 : val)
* this.left = (left===undefined ? null : left)
* this.right = (right===undefined ? null : right)
* }
*/
/**
* @param {TreeNode} root
* @return {number[]}
*/
var inorderTraversal = function (root) {
const answer = [];
function inorder(root) {
if (!root) return;
inorder(root.left);
answer.push(root.val);
inorder(root.right);
}
inorder(root);
return answer;
};
๋ฐ์ํ
'๐ algorithm > leetcode' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
LeetCode 54 - Spiral Matrix (Medium) (0) | 2021.03.03 |
---|---|
LeetCode 279 - Perfect Squares (Medium) (0) | 2021.03.03 |
LeetCode 394 - Decode String (Medium) (0) | 2021.03.03 |
LeetCode 78 - Subsets (Medium) (0) | 2021.03.03 |
LeetCode 739 - Daily Temperatures (Medium) (0) | 2021.03.03 |
๐ฌ ๋๊ธ