Min Path Sum

// recursive is straight forward
    public static int getMinPathSum(TreeNode root) {
        if (root == null) return 0;
        int left = getMinPathSum(root.left);
        int right = getMinPathSum(root.right);
        return root.val + Math.min(left, right);
    }

results matching ""

    No results matching ""