← All problemsSign in

RECURSION LOVE

An array(a) of N elements is given which represents one of the permutations of 1 to N numbers. int fun( int curr_ind, int itr ) { if(itr==0) return 0; return a[curr_ind] + fun( a[curr_ind] , itr-1 ); } ###Input: The first line contains T, the number of test cases. The second line of the input contains 2 space-separated integers, N and Q denoting the siz

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