diff --git a/Sample.cs b/Sample.cs new file mode 100644 index 00000000..7370a037 --- /dev/null +++ b/Sample.cs @@ -0,0 +1,43 @@ +//Time Complexity = O(n*2) +//Space Complexity = O(n*2) +public class Solution { + public IList> Generate(int numRows) { + int[][] arr = new int[numRows][]; // Create an array with numRows outer elements + + for (int i = 0; i < numRows; i++) + { + arr[i] = new int[numRows]; // Initialize each inner array + } + IList> result = new List>(); + IList innerList = new List(); + int m = numRows; + if(numRows<=0) + { + return result; + } + innerList.Add(1); + result.Add(innerList); + if (numRows ==1) + { + return result; + } + + for(int i=1; i< m; i++) + { + innerList = new List(); + int n = i+1; + arr[i][0]=1; + innerList.Add(arr[i][0]); + arr[i][n-1] = 1; + + for(int j = 1;j