Skip to content

Conversation

@s-bhalode
Copy link

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

  1. First I have created a vector of vector named as result with the size of n.
  2. Then I have iterated a loop till n rows in which I have resized the vector at index i by i+1 size.
  3. After resizing the inner vector, I have replaced the current element value by the sum of the two numbers directly above it.
  4. Then return the required resultant.

pascal triangle

@welcome
Copy link

welcome bot commented Sep 8, 2023

I can tell this is your first pull request! Thank you I'm so honored. 🎉🎉🎉 I'll take a look at it ASAP!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant