I feel like my code is more clear and concise than the OP's code. It's just my opinion and I feel like I should contribute back thus posting it. ``` int get_first(int v, int tl, int tr, int l, int r, int x) { if(r < tl || tr < l || t[v] <= x) return -1; if(tl == tr) { return tl; } else { int tm = (tl + tr) / 2; int res = get_first(v*2, tl, tm, l , min(tm, r), x); if(res != -1) return res; return get_first(v*2+1, tm+1, tr, max(tm+1, l), r, x); } } ```