LeetCode-Solutions icon indicating copy to clipboard operation
LeetCode-Solutions copied to clipboard

pascals triangle daily challenge question

Open s-bhalode opened this issue 2 years ago • 1 comments

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

s-bhalode avatar Sep 08 '23 16:09 s-bhalode

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!

welcome[bot] avatar Sep 08 '23 16:09 welcome[bot]