Obtain the Sum
Chef is given two integers $N, S$. Consider an array $A$ of size $N$ such that $A[i]=i$ for every $1 \leq i \leq N$. You are required to find any position $x(1\leq x \leq N)$ such that : $(A[1]+A[2]+...A[x-1]) + (A[x+1]+A[x+2]+...A[N]) = S$ If there are multiple such positions $x$, print any such position. If there is no such position, print $-1$. ### Input - First line will contain $T$, numb
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