DEV Community

schudy
schudy

Posted on

LeetCode 27

Use two pointers to search the target val.
One pointer 'j' is the slow one, only go forward by 1 if the other fast pointer's 'i''s value is not the target val. In this case, it will be replaced by the fast pointer's 'i' value. 'i' search entire array. If 'i' point to the target value, it does nothing, just go to the next one.
Alt Text

Top comments (0)