update pascals-triangle solution by using o(k) space.