We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Delete a Node
Delete a Node
Sort by
recency
|
836 Discussions
|
Please Login in order to post a comment
if (!root) return nullptr; if (key < root->val) { root->left = deleteNode(root->left, key); } else if (key > root->val) { root->right = deleteNode(root->right, key); } else { // Node to be deleted found if (!root->left) { TreeNode* rightChild = root->right; delete root; return rightChild; } if (!root->right) { TreeNode* leftChild = root->left; delete root; return leftChild; }
}
public static SinglyLinkedListNode? deleteNode(SinglyLinkedListNode? llist, int position) { if(llist == null) { return null; }
it show: error CS0103: The name 'deleteNode' does not exist in the current context....
Computer Fundamentals
if(llist == null) return null;
Java 8 Solution: