[LintCode] Segment Tree Build
public SegmentTreeNode build(int start, int end) { // write your code here if(start > end) return null; SegmentTreeNode root = new SegmentTreeNode(start, end); // root if(start < end) { int mid = start + (end - start) / 2; root.left = build(start, mid); root.right = build(mid+1, end); } return root; }
Leave A Comment