Not showing right output

Here… It is printing rigth subsequence for length -2 but not for more than -2.


I want to implement this logic for more than 2 length… Please help

@ashishnnnnn do this using character array it will be simple then
using string makes it very complex

Is my logic is correct…along with code… I am not implementing the video logic

@ashishnnnnn no it dont seem right thats why saying do with char arrays

Here i am using substring method thus i had used string… But it is some problem in logic that why it is not giving right answer to this…
Can you implement this logic…using character array

@ashishnnnnn explain your logic here

Is there another way to explain the logic…other than writing…
I won’t be able to explain it by writing

@ashishnnnnn best way is if you understand your logic dry run your code yourself to found the error

I have found the error… But not able to correct it and implement the logic in code in rigth way…
What should i do

@ashishnnnnn then try watching the video and that logic only it’s explained very clearly