Algorithms icon indicating copy to clipboard operation
Algorithms copied to clipboard

Add 2 variations of solution2(), with space complexity = O(n/2) and O(1) respectively.

Open kuchaguangjie opened this issue 4 years ago • 0 comments
trafficstars

  • solution2a(), only create an array half the size of solution2(), since all odd indices have value 0.
  • solution2b(), only create 3 variables, since to calculate column n, only need to remember state of column n-2 and n-4.

kuchaguangjie avatar Feb 28 '21 01:02 kuchaguangjie