1 Count problem


I am getting correct length but I also have to print the array .
So How Should I Update It.
I have used recursion with memoisation.