Hi, i am just starting out trees and not sure why am i getting a runtime error on this one.

```
class Solution {
public:
TreeNode* findmin(TreeNode* root){
if(root==NULL)
return NULL;
while(root->left!=NULL){
root=root->left;
}
return root;
}
TreeNode* trimBST(TreeNode* root, int l, int r) {
if(root==NULL) return root;
else if(root->val>=l && root->val<=r){
// cout<<root->val<<" "<<l<<" "<<r<<endl;
root->left=trimBST(root->left,l,r);
root->right=trimBST(root->right,l,r);
int flaf=1;
}
else{
// cout<<"going to delete mr "<<root->val<<endl;
//no child
if(root->left==NULL and root->right==NULL){
delete root;
root=NULL;
}
//1 child
else if(root->left==NULL){
TreeNode* temp=root;
root=root->right;
delete temp;
}
else if(root->right==NULL){
TreeNode* temp=root;
root=root->left;
delete temp;
}
//2 child
else{
TreeNode* temp=findmin(root->right);
root->val=temp->val;
root->right=trimBST(root->right,l,r);
}
}
return root;
}
};
```

It’s is showing error on this test case

[1,null,2]

2

4