[Leetcode Pattern] - Array, String

Array, String

Contents

Array and string topic can usually treated as the similar topic, so today we are going to learn the most common design pattern for those two topics.

  • Using two different pointer to frame out the current processing array while traversing the array
  • Implement the various size sliding window

  • Kadane’s Algorithm: Iterative dynamic programming algorithm

  • A range of frame to traverse the array
  • Check for the count of the unique element contains in the frame
  • Sort the array to the ascending/descending order.
  • If the problem has stated that the array is sorted, you might have to consider whether there isn’t there binary search method or while traversing the array, you can optimize the scanning time by skipping the duplicated value.