I did not said that stack can be used to solve the problem - I asked to explore if its possible to solve it using stack, and if yes then how.

The answer for some data structures can be no because we can’t blindly apply any data structure to any problem.