LeetCode_701

Yesl·2022년 9월 25일

LeetCode

목록 보기
4/5
class Solution {
    
public:
    
    TreeNode* insertIntoBST (TreeNode* root, int val) {
        
        if (root == NULL) {
            return new TreeNode (val);
        }
        
        else if (val < root -> val) {
            root -> left = insertIntoBST (root -> left, val);
        }
        
        else if (val > root -> val) {
            root -> right = insertIntoBST (root -> right, val);
        }
        
        return root;
    }
};


성공쓰!

profile
Studying for "Good Health & Well-Being"...

0개의 댓글