Hey there!
I came across this problem [](https://www.spoj.com/problems/JNEXT/) under the tag of stack and queues and would like to know the solution for the same. I got it accepted using basic logic but couldn't find any solution using stacks or queues.
Thanks in advance.
search std::next_permutation on google.