Typo in Intersection of Two Sorted Arrays 13.1 Java


In the most optimal O(m+n) solution, when a common element has been added and the pointers advance to the next element in both the arrays and both elements are the same again, the array pointer in the else condition will advance as per the code, contrary to what is written that both pointers will advance. It doesn’t seem possible for both pointers to advance at the same time without adding the common element (without set). Execution seems right but the explanation doesn’t match. Please correct me if I am mistaken.