[LintCode] Segment Tree Query II
1 2 3 4 5 6 7 8 |
public int query(SegmentTreeNode root, int start, int end) { // write your code here if(root == null || root.end < start || root.start > end) return 0; if(root.start == root.end) return root.count; return query(root.left, start,end)+ query(root.right, start, end); } |
Leave A Comment