Problem B, which was ternary string, where we basically had only letters of one, two and three.
And you should print the shortest subsequence, which has each type of letter or at least once.
Yeah.
So one, two and three.
Basically what they did was a sliding window approach because I felt about two pointers.
Right.
That makes sense.
I mean, you move the right pointer and you try to maximize the left pointer as much as you can while
still having all those digits in the subsequent.
So, yeah, that makes sense.
But I don't know, it's still a B of D two.
So maybe there are some simpler approaches.
But yeah.
So yeah.
This was really straightforward.
Just to start to warm up a little bit until everybody's okay to start with problem B..
So yeah, I just had a frequency array.
Ten digits.
You don't need 10.
You need only three.
And what I did is that I iterated with the right point, which I called J.
I incremented its frequency.
If this frequency becomes one, then I have encountered the number of distinct digits.
And of course, while I can.
So as much as I can.
I'm gonna increment I.
Right.
So while I is less for equal, then g I try to increment I.
So I decrease its frequency and I check if that frequency becomes known as zero.
That means I have one distinct digit less.
So I am going to decrement the counter.
Right.
So I do that.
And if the counter is no less than free.
Obviously I did something wrong.
So I have to go back with that.
I.
So this is exactly what I check.
If countries less than free, I break.
Because if I can't decide, I can't in the future anymore.
And then because I have to come back to the previous I just the chrome and the AI and increase again
its frequency and update the counter.
And if counter is free, that means this minimum sequence for this right pointer.
G have to be considered for a possible answer.
And I just obedience.
So yeah.
That was problem B just to warm up.
I did a sliding window approach.