I get TLE error


This is my code and I’ve used recursion and i get TLE error. Can you help me in making this code faster while using recursion? Also I think the way of using two arrays to take the input is inefficient so can you tell me a way to take multiple test cases from the user in an efficient way.

hello @amanb25
furthur optimisation involves dynamic programming so i would suggest to solve this problem after studying dp.

no need to store all test cases .
just write a program for single case and put that code inside while loop.

for example suppose u are given t test cases and in each test case u need to take input and show the same number as output.

logic for a single case.
cin>>n;
cout<<n;

now for t test case put ur logic inside while loop.
something like.
while(t–) {
cin>>n;
cout<<n;
}