Got AC because the parameter can be changed


#1

vector Solution::inorderTraversal(TreeNode* A) {
stack< TreeNode* > s1;
vectorans;
if(A==NULL)
return ans;

s1.push(A);
while(!s1.empty())
{
    TreeNode* temp = s1.top();
    if(temp->left==NULL)
    {
        ans.push_back(temp->val);
        s1.pop();
        if(temp->right!=NULL)
        {
            s1.push(temp->right);
            temp->right=NULL;
        }
        
    }
    else
    {
        s1.push(temp->left);
        temp->left=NULL;
    }
    
}

return ans;

}