Isn't the point of having 2 pointers is to have them move together?
I think if you rewrite your if / else chain a little bit and break it out into 2 separate if blocks, then you can always decrease i and j together (at least until one of them reaches 0).
We're a place where coders share, stay up-to-date and grow their careers.
Isn't the point of having 2 pointers is to have them move together?
I think if you rewrite your if / else chain a little bit and break it out into 2 separate if blocks, then you can always decrease i and j together (at least until one of them reaches 0).