Could you help me with the code?

Hi @ysurange1998

You can directly use stl next_permutation.

Link : https://ide.codingblocks.com/s/213269

Hope it Helps.