My 1 line C++ code


  • 0
    K
    • oneline code, beat 70% cpp codes
    bool isSameTree(TreeNode* p, TreeNode* q) {
        return (p && q)?(p->val==q->val && isSameTree(p->left,q->left) && isSameTree(p->right,q->right)):(!p && !q);
    }
    

Log in to reply
 

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