Alyona and strings problem

can you please tell why are we doing rem-1 if cont==1 in a function call bcoz cont==1 means we want to continue then why will we reduce the rem value and at the same time no doing rem-1 when cont==0 bcoz that would mean that we want to terminate this subsequence now??

yes i am talking about the alyona and strings problem code written by saiyam bhaiya

We need to consider all the possible cases ,that’s why. If cont==1 , it just means that sequence was running at the index before and we didn’t reduce rem then. So we had 2 choices either to continue with the current substring (where we pass cont as 1 and don’t reduce rem) or we try to start a new sequence.

Similarly when cont==0, we have 2 choices next time, either to continue or terminate and start a new.
So cont is the state up until previous index, what was the sequence state before this index.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.