4- remove duplicates from the sorted array

Solution to a problem-solving ideas: The simplest idea is for each element, front to back scan for comparison with other elements, such as the presence of repetitive elements is deleted

Attention to the need j-- after deleting an element, because the length of the array will change immediately, the latter will forward the elements, j should also move forward accordingly.

Outline of Solution Solution two: a comparison element and b, if not equal, with a covering position behind b

 

Again scanning, fast execution speed.

 

Guess you like

Origin www.cnblogs.com/lsh0908/p/11426373.html