{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.
\n", "\n", "
\n",
"In Pascal's triangle, each number is the sum of the two numbers directly above it.
Example:
\n", "\n", "Input: 5\n",
"Output:\n",
"[\n",
" [1],\n",
" [1,1],\n",
" [1,2,1],\n",
" [1,3,3,1],\n",
" [1,4,6,4,1]\n",
"]\n",
"\n",
"\n",
"\n",
"\n", "Source \n", "
Solve it both recursively and iteratively.
\n", "\n", "