← All problemsSign in

Love of Toys

Kara loves toys. There are *N* piles of toys aligned in a straight line in front of her. The **i-th** pile contains *Ai* number of toys. Kara will walk from the **1-st pile** towards the **N-th** pile, and she wants to collect toys from each pile without walking back. When Kara reaches the **i-th** pile, she can take toys of that pile if and only if **|Z-Ai|<=Y**, where *Y* is a fixed integer, *Z

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