I am unable to find the mistake in my code. It gives two test cases wrong. https://ide.codingblocks.com/s/110853
Also I want to know is there any better approach to solve this problem. Even with the use of DP?
Recursion-Dictionary Order Doubt
I have modified your code a bit, try to submit it now.
What is the exact reason that we donot backtrack in this question?
Backtracking here is based on the order of strings you need to print in output. You can backtrack and see the result. You yourself will be able to see that the strings obtained will be different you need in output.