I am implementing the solution for this question. This question is similar to the one discussed in Coding Blocks Tree section, except that instead of inorder, we want to flatten the tree in a preorder manner.
I have modified Prateek Sir’s approach but my solution is only partially correct.
Example for this input, the flattened answer and the preorder answer differs.
Where am I going wrong?