HR30 Day 22: Binary Search Trees

1 개요[ | ]

HR30 Day 22: Binary Search Trees
해커랭크 30 Days of Code
문제 풀이
20-29 Day e
HR30 Day 20: Sorting

HR30 Day 21: Generics

HR30 Day 22: Binary Search Trees

HR30 Day 23: BST Level-Order Traversal

HR30 Day 24: More Linked Lists

HR30 Day 25: Running Time and Complexity

HR30 Day 26: Nested Logic

HR30 Day 27: Testing

HR30 Day 28: RegEx, Patterns, and Intro to Databases

HR30 Day 29: Bitwise AND

2 Java[ | ]

    public static int getHeight(Node root){
        //Write your code here
        if( root == null ) return -1;
        int left = getHeight(root.left);
        int right = getHeight(root.right);
        return Math.max(left, right) + 1;
    }

3 PHP[ | ]

    public function getHeight($root){
        //Write your code here
        if( is_null($root) ) return -1;
        $left = $this->getHeight($root->left);
        $right = $this->getHeight($root->right);
        return max($left, $right)+1;
    }
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}