Binsearch
Chef has just finished practicing binary search and tries to perform it on permutations. For a permutation $P$ of length $N$, Chef wants to find a particular number $X$ in the permutation. To do this, he calls the function `binsearch`$(P, 1, N, X)$: ```cpp long long int binsearch(int P[], int L, int R, int X) { if(L>R) return 0; int MID = (L + R) / 2; if(P[MID] == X || L =
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start