LeetCode-Solutions
LeetCode-Solutions copied to clipboard
pascals triangle daily challenge question
Pascal's Triangle
Successfully accepted Runtime : 3ms Time Complexity : O(n^2) Memory : 6.7 MB
In this problem we have to return first n rows of pascal's triangle. In this triangle each number is sum of the two numbers directly above it.
Intuition :- DP Solution
- First I have created a vector of vector named as result with the size of n.
- Then I have iterated a loop till n rows in which I have resized the vector at index i by i+1 size.
- After resizing the inner vector, I have replaced the current element value by the sum of the two numbers directly above it.
- Then return the required resultant.
I can tell this is your first pull request! Thank you I'm so honored. :tada::tada::tada: I'll take a look at it ASAP!