leetcode 118 Pascal’s Triangle || 119 Pascal’s Triangle II

本次题解包括

  • 118. Pascal’s Triangle
  • 119. Pascal’s Triangle II

118. Pascal’s Triangle

Given numRows, generate the first numRows of Pascal’s triangle.

For example, given numRows = 5,
Return

题目地址:leetcode Pascal’s Triangle

题目大意:给定n返回前n行杨辉三角

思路:看代码吧

C++

Python

 

 


 

119. Pascal’s Triangle II

Given an index k, return the kth row of the Pascal’s triangle.

For example, given k = 3,
Return [1,3,3,1].

Note:
Could you optimize your algorithm to use only O(k) extra space?

题目地址:leetcode Pascal’s Triangle II

题目大意:给定n返回第n行杨辉三角(下标从0开始)

思路:看代码

C++

Python

本文是leetcode如下的题解

  • 118. Pascal’s Triangle
  • 119. Pascal’s Triangle II

更多题解可以查看: https://www.hrwhisper.me/leetcode-algorithm-solution/

本博客若无特殊说明则由 hrwhisper 原创发布
转载请点名出处:细语呢喃 > leetcode 118 Pascal’s Triangle || 119 Pascal’s Triangle II
本文地址:https://www.hrwhisper.me/leetcode-pascals-triangle-or-pascals-triangle-ii/

打赏一杯咖啡钱呗

codes, Leetcode , . permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *