update triangle solution using o(n) space. bottom-up approach