Start from Difficulty 1:
1, Remove specified elem from unsorted array: 2 pointers, one is to iterate all the elements in the array, the other is to increase if current value is not equal to specified element.
2, Remove duplicates from sorted array: still 2 pointers, compare current value with previous.
3, Remove 3rd duplicate from sorted array: on 2, have another var to store the appearance number.
4, Remove duplites from sorted linked list: prev & curr, then pay attention to null head input.
时间: 2024-12-12 16:46:21