Identifier Expected Issue when declaring helper method


  • 0

    public class Solution {

      public TreeNode sortedArrayToBST(int[] nums) {
        if(nums.length=0) return null;
        TreeNode head = helper(nums, 0, nums.length - 1);
        return head;
    }
    
    public TreeNode helper(int[] num, low,high){
            if(low>high) return null;
            int mid = (low + high) / 2;
            TreeNode node = new TreeNode(num[mid]);
            node.left = helper(num, low, mid - 1);
            node.right = helper(num, mid + 1, high);
            return node;
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.