In this problem while solvig getting the error use of undeclared identifer null
https://leetcode.com/problems/count-univalue-subtrees/solution/
Below is my solution any one have any idea why this is happening?
/**
Definition for a binary tree node.
struct TreeNode {
int val;TreeNode *left;TreeNode *right;TreeNode() : val(0), left(nullptr), right(nullptr) {}TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}};
*/
#include <stddef.h>
class Solution {
public:
#include <stddef.h>
int count=0;
bool isit(TreeNode node){
if (node.left == null && node.right == null) {
// found a univalue subtree - increment
count++;
return true;
}
boolean is_unival = true;
// check if all of the node's children are univalue subtrees and if they have the same value
// also recursively call is_uni for children
if (node.left != null) {
is_unival = is_uni(node.left) && is_unival && node.left.val == node.val;
}
if (node.right != null) {
is_unival = is_uni(node.right) && is_unival && node.right.val == node.val;
}
// return if a univalue tree exists here and increment if it does
if (!is_unival) return false;
count++;
return true;
}
int countUnivalSubtrees(TreeNode* root) {
if (root == null) return 0;
is_uni(root);
return count;
}
};