You are given the root of a Binary Search Tree (BST) and an integer key. Your task is to delete the node with the given key from the BST while maintaining the BST properties and return the root of the updated tree.
When deleting a node:
If the key does not exist, return the original tree unchanged.
Input: root = [5,3,6,2,4,null,7], key = 3
Output: [5,4,6,2,null,null,7]
Explanation: The node with value 3 is deleted while maintaining the BST property.
Input: root = [5,3,6,2,4,null,7], key = 0
Output: [5,3,6,2,4,null,7]
Explanation: The key does not exist, so the BST remains unchanged.
Input: root = [1], key = 1
Output: []
Explanation: The only node is deleted, resulting in an empty BST.
Sign in to write, run, and submit your solution against the full test suite.