From 4b07d07d1fedacef44dd67517e3f8475d82dad84 Mon Sep 17 00:00:00 2001 From: Dhrit Patel Date: Wed, 9 Oct 2024 13:56:29 -0700 Subject: [PATCH] Done --- Problem-1.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Problem-1.py diff --git a/Problem-1.py b/Problem-1.py new file mode 100644 index 00000000..59b39043 --- /dev/null +++ b/Problem-1.py @@ -0,0 +1,16 @@ +# T.C = O(numRows^2) S.C = O(numRows^2) +# Have made 2d array with all the values 1 becuase we need 1 at start and end and take the above row and column for addition +class Solution(object): + def generate(self, numRows): + """ + :type numRows: int + :rtype: List[List[int]] + """ + + result= [[1] * (i + 1) for i in range(numRows)] + for i in range(numRows): + for j in range(1,i): + result[i][j] = result[i-1][j-1] + result[i-1][j] + return result + + \ No newline at end of file