2015年12月9日星期三

Algorithm -- Two Pointers

Two pointers is an useful algorithm to deal with Array and String and Linked-List
  • Actually, most linked list problem can be solved by this algorithm
  • Two pointers is one basic algorithm and used widely. One typical origination is quickSort. 

A few subtypes
  • two pointers move from left to right, slide window 
  • two pointers move from left, right to middle 
  • two pointers control two array or list, typically merging

Merge Two Sorted Array
Replicate Duplicates from Single Sorted Array
Reverse Words in a String
Rotate Array

没有评论:

发表评论