This is the next permutation problem on leetcode.
So what exactly is the next permutation of a number?
How do we find the next permutation through a code?
What observations are required?
Please note that after looking at the video, try to solve the problem using that logic. That's more important. Keep practicing and observing.