00:01
Okay, so in this question we want to find the next lexographical order.
00:04
So you'll notice that four is greater than two, so we don't do anything for that.
00:09
Then three is also greater than two, so we don't do anything for that.
00:12
Then we will switch this four and three together.
00:16
So we get one, four, three, two.
00:20
But we can find a smaller number than this by simply switching this three and two together.
00:25
So this is not your lexic graphical order.
00:27
It's just one, four, two and three.
00:32
So for b, 4, 5, 3, 2, 1, what you will do is, well, this 5 is switches places with 4 because that's the last switch index.
00:50
So then this switches to 5, 4, 3, 2, 1.
00:54
But then if you look at this sub number, well, obviously, if you rearrange this, it'll be 1, 2, 3, 4, and that will be your smallest.
01:01
So instead of this one, it'll be five and one, two, three, four.
01:09
So if we'll see, one, two, three, four, five.
01:15
So your next largest integer would be, it's not swapping by two because if you swap this index, or even if you swap five here, because if you swap five of two, then that'd be smaller...