GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Leetcode-Java/leetcode/solution/src/DeleteNodeInBST.java at master · Tulpen/Leetcode-Java Expand file tree/ Copy pathDeleteNodeInBST.javaMore file actions 29 lines (25 loc) · 769 Bytes / Copy pathDeleteNodeInBST.javaFile metadata and controls29 lines (25 loc) · 769 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 public class DeleteNodeInBST { public TreeNode deleteNode(TreeNode root, int key) { if (root == null) { return null; } if (key < root.val) { root.left = deleteNode(root.left, key); } else if (key > root.val) { root.right = deleteNode(root.right, key); } else { if (root.left == null) { return root.right; } else if (root.right == null) { return root.left; } TreeNode node = root.right; while (node.left != null) { node = node.left; } root.val = node.val; root.right = deleteNode(root.right, node.val); } return root; } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |