← All problemsSign in

Shriraj and Gifts

As everybody knows Shriraj is (almost) always happy. Shriraj also wants to make others happy, and he has an idea similar to Secret Santa. Shriraj selects n sad people whom he numbers from 1 to n. Now he creates an array p of all the numbers from 1 to n such that the ith member will give the gift to the p[i]th member. Shriraj ensures that each person receives exactly one gift. However things don'

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