Navan Interview Question

similar to pascal triangle with recursion and optimization