One line Buggy code

  • 0

    // Just a naive idea (good for java). Hadn't freed memory yet.
    TreeNode* trimBST(TreeNode* root, int L, int R) {
    return !root ? NULL : (root->left = trimBST(root->left, L, R), root->right = trimBST(root->right, L, R), (L<=root->val&&root->val<=R) ? root : (root->val > R ? root->left : root->right));

Log in to reply

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