Youwang Deng

I'm a software developer, familiar with C#, Java, JavaScript, focus on full stack development.

Leetcode Array Note

01 Jul 2019 » Leetcode-Array

Array - linear data structure

  • index(pointer) manipulation
  • check bound in loop
  • skip element to avoid duplicate
  • element remove, replace, partation
  • use HashMap to cache data
  • two pointers used on sorted array
  • math logic usually related with swap and reverse
  • 2D index manipulation
  • use boolean array to cache used or visited state
  • consider each element and then combine the result
  • digits manipulation, use of a carry state
  • int[] arr = new int[n+1]
  • In place manipulation
    • use one pointer to move
    • use two pointers to swap
    • use value to store state, 0 or 1, or use equations to generate multiply states
  • index usually involved with ‘+1’ or ‘-1
  • usage of sum
  • two pass, forward and backword
  • shift k position – triple reversion – (n-k)(1),k(2), n(3)
  • slidig window and Map or Set or TreeMap or TreeSet(ceiling(x), floor(x))
  • update min1 and min2 pointer