Skip to content

Commit 7fec7d5

Browse files
refactor 272
1 parent 92059e4 commit 7fec7d5

File tree

1 file changed

+0
-22
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-22
lines changed

src/main/java/com/fishercoder/solutions/_272.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,6 @@
66
import java.util.List;
77
import java.util.Stack;
88

9-
/**
10-
* 272. Closest Binary Search Tree Value II
11-
*
12-
* Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target.
13-
14-
Note:
15-
Given target value is a floating point.
16-
You may assume k is always valid, that is: k ≤ total nodes.
17-
You are guaranteed to have only one unique set of k values in the BST that are closest to the target.
18-
Follow up:
19-
Assume that the BST is balanced, could you solve it in less than O(n) runtime (where n = total nodes)?
20-
21-
Hint:
22-
23-
Consider implement these two helper functions:
24-
getPredecessor(N), which returns the next smaller node to N.
25-
getSuccessor(N), which returns the next larger node to N.
26-
Try to assume that each node has a parent pointer, it makes the problem much easier.
27-
Without parent pointer we just need to keep track of the path from the root to the current node using a stack.
28-
You would need two stacks to track the path in finding predecessor and successor node separately.
29-
30-
*/
319
public class _272 {
3210

3311
public static class Solution1 {

0 commit comments

Comments
 (0)