public SegmentTree build(int start, int end) { if (start > end) { return null; } SegmentTree root = new SegmentTree(start, end); if (start == end) { return root; } int mid = start + ((end - start) >> 1); root.left = build(start, mid); root.right = build(mid + 1, end); return root; }