← All problemsSign in

The Fear Calculator

CodeChefRating 2146Open on judge ↗

Abdul always suffered from anxiety and fear. To understand him better, the ingenious Doctor used a complex method to calculate his fear. The doctor wants to automate the process and hence needs your help! Given an array $A$ of $N$ integers you have to find the index of the first smaller element to the right of every index $i$, let it be $j$, then the $fear[i]$ of the index would be $j + 1 -i$, an

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start