Doubt on using recursion logic

Could you help me where I am going wrong with this logic?

hello @PThak2018
ur logic looks correct to me.
can u pls share a running code so that i can check where it is failing(as i m not familiar with java)


Getting stack overflow error. Some problem with base condition i guess that;s why it is giving this error.

hello @PThak2018

this is the culprit for the same. here u are never incrementing ur index which is causing in infinite recursion.
remove this complete line because it will give same output as smalloutput1.

Thanks Aman :slight_smile:

Hi,
https://ide.codingblocks.com/s/250938.

Please go through the code. This is passing for all the test cases on coding blocks environment but ideally is should not.
I have used a test case in the above code where this is failing. May be we need to add more test cases to the problem in coding blocks IDE.
Also, if you can help without changing the logic?

image
why u have commented this part,
this should be there in ur array so uncomment it in place of smalloutput2 use smalloutput1.

Hi Aman,

image

Loop is there on smallOutput1. But this code is running for all test cases in Coding Blocks IDE and as shown previously, it is failing for one test cases. The test cases needs to be updated on Coding blocks IDE.

no this loop is for including arr[index],
u need to add one more loop when for excluding arr[index].
and in that simply append smalloutput1 in output