The Double Pointer Method to Solve the Problem of Array Characteristic Bits

The double pointer method is to use two pointers to point to the head and tail of the array, and move to the middle after the loop starts. Or it points to the beginning or the end of the data at the same time. When looping, the speed increases according to different judgment conditions.
The double pointer method is used to solve the search and modification of specific data in the array, and it is very convenient to find some features in the array.

Common solutions:
1. Remove duplicates from sorted array: https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/
2. Remove elements: https://leetcode-cn. com/problems/remove-element/
3. The linked list determines whether there is a cycle: https://leetcode-cn.com/problems/linked-list-cycle/

Other article references:
https://segmentfault.com/a/1190000014103659
https://www.cnblogs.com/codingstory/p/11334827.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324069795&siteId=291194637