Count subsequences bitset

My approach- I stored all the subsequences in a ‘set’. And after that i printed the length of set so that the same subsequence will be eliminated. But i am getting runtime error for strings of length>3

my code link- https://ide.codingblocks.com/s/68462

Hi Tanay, there’s no Runtime Error for strings of length > 3 however, the ans printed is wrong for all testcases except the first one. This is happening because after the first testcase is processed and second testcase is being processed the set stores the answer for previous testcases also. You may see that when you give only 1 testcase at a time the answer from your code is correct. The global definition of the set is posing this problem. Please try to rectify this by using either any of the set methods( mind their time complexities) from STL or change it’s definition. It will work then. Rest is fine.

Hope this helps :slight_smile:

Hey Tanay,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.