/**
* Definition of TreeNode:
* public class TreeNode {
* public int val;
* public TreeNode left, right;
* public TreeNode(int val) {
* this.val = val;
* this.left = this.right = null;
* }
* }
*/
public class Solution {
ArrayList<Integer> result =
new ArrayList<>();
public List<Integer>
searchRange(TreeNode root,
int k1,
int k2) {
inOrder(root, k1, k2);
return result;
}
private void inOrder(TreeNode root,
int k1,
int k2) {
if(root ==
null)
return;
inOrder(root.left, k1, k2);
if(root.val <= k2 && root.val >= k1) {
result.add(root.val);
}
inOrder(root.right, k1, k2);
}
}