private boolean largestBSTSubtreeHelper(TreeNode root, long[] min, long[] max, int[] result) {
		if (root == null) return true;
		
		int[] leftResult = new int[]{0};
		int[] rightResult = new int[]{0};
		long[] leftMax = new long[]{Long.MAX_VALUE}, leftMin = new long[]{Long.MIN_VALUE};
		long[] rightMax = new long[]{Long.MAX_VALUE}, rightMin = new long[]{Long.MIN_VALUE};
		
		boolean left = largestBSTSubtreeHelper(root.left, leftMin, leftMax, leftResult);
		boolean right = largestBSTSubtreeHelper(root.right, rightMin, rightMax, rightResult);

		if (left && right) {
			if ((root.left == null || root.val > leftMax[0]) && (root.right == null || root.val < rightMin[0])) {
				result[0] = leftResult[0] + rightResult[0] + 1;
				min[0] = root.left != null ? leftMin[0] : root.val;
				max[0] = root.right != null ? rightMax[0] : root.val;
				
				return true;
			}
		}
		
		result[0] = Math.max(leftResult[0], rightResult[0]);
		
		return false;
	}