← All problemsSign in

Sweta reaching the end of array

Sweta has an array of integers. She has to start from the first index and reach the end. The only steps she can take are $+3$ or $-1$. Cost of a path is equal to the sum of all integers in the path. Help her to find the cost of the lowest cost path. If no path is possible, print $-1$. ### Input - First line will contain $T$, number of testcases. Then the testcases follow. - In each test case, fir

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