Binary to Doblly linklist

My code is not giving the correct output for this question please tell me how can i do it right.
Question LINK:: https://practice.geeksforgeeks.org/problems/binary-tree-to-dll/1
Code link:: https://ide.codingblocks.com/s/103397

@sunny.kumar2016
The problem with your code is that you are using the prev pointer as static. First of all I would suggest you to pick some other name as ‘prev’ is a defined keyword in C++ and might create some complications due to ambiguous calls to your pointer and the template class.
Secondly , since you are using it as a static variable it retains its memory over recursive calls. While you want this effect for a single testcase , the problem is that the pointer continues to retain its memory over multiple testcases and hence gives the wrong output.
‘prev’ needs to initialised to NULL for every individual testcase or your code does not work. In your code it only gets NULL for the first testcase and then the following testcases gets ruined.

So how can i correct that do i need to make another function and pass head_ref of ll as reference and do these steps in that function??

@sunny.kumar2016
Try this - https://ide.codingblocks.com/s/103506
I made a helper function and practically copied your entire code. I only made slight modifications to work the ‘prevNode’ variable for different testcases.
Note that I changed the name of ‘prev’ variable to ‘prevNode’ because of the above mentioned reason.

https://practice.geeksforgeeks.org/problems/smallest-window-in-a-string-containing-all-the-characters-of-another-string/0 Sir for the above question how will i check every time that wheather all the characters of text are being visited or not if i use sliding window technique it will become very unoptimized please tell me a solution for it