当前位置:网站首页>119. Pascal‘s Triangle II. Sol
119. Pascal‘s Triangle II. Sol
2022-07-05 22:17:00 【isee_ nh】
Easy Difficult questions , It's actually binomial expansion , You don't need recursion
Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:

Example 1:
Input: rowIndex = 3 Output: [1,3,3,1]
Example 2:
Input: rowIndex = 0 Output: [1]
Example 3:
Input: rowIndex = 1 Output: [1,1]
Constraints:
0 <= rowIndex <= 33class Solution: def fraction(self, n): product = 1 if n==0: return 1 else: for i in range(n): product = product*(i+1) return product def Pr(self, n, m): return self.fraction(n)/(self.fraction(m)*self.fraction(n-m)) def getRow(self, rowIndex): output = [] for i in range(rowIndex+1): output.append(int(self.Pr(rowIndex,i))) return output
边栏推荐
- Practice: fabric user certificate revocation operation process
- Web3为互联网带来了哪些改变?
- Performance monitoring of database tuning solutions
- Server optimization of performance tuning methodology
- FBO and RBO disappeared in webgpu
- MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
- Storage optimization of performance tuning methodology
- 阿龙的感悟
- Countdown to 92 days, the strategy for the provincial preparation of the Blue Bridge Cup is coming~
- Recovery technology with checkpoints
猜你喜欢

【愚公系列】2022年7月 Go教学课程 004-Go代码注释

Implementation technology of recovery

Index optimization of performance tuning methodology

The real situation of programmers

Two stage locking protocol for concurrency control

2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*

Common interview questions of redis factory

Calculation method of boundary IOU

Storage optimization of performance tuning methodology

Metaverse Ape猿界应邀出席2022·粤港澳大湾区元宇宙和web3.0主题峰会,分享猿界在Web3时代从技术到应用的文明进化历程
随机推荐
Granularity of blocking of concurrency control
Platformio create libopencm3 + FreeRTOS project
数博会精彩回顾 | 彰显科研实力,中创算力荣获数字化影响力企业奖
如何快速体验OneOS
Database tuning solution
Analyse des risques liés aux liaisons de microservices
[Yugong series] go teaching course 003-ide installation and basic use in July 2022
Sub total of Pico development
元宇宙中的三大“派系”
微服務鏈路風險分析
Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
MySQL actual combat 45 lecture learning (I)
【愚公系列】2022年7月 Go教学课程 003-IDE的安装和基本使用
Summary of El and JSTL precautions
Shell script, awk condition judgment and logic comparison &||
Common interview questions of redis factory
Recovery technology with checkpoints
极狐公司官方澄清声明
了解 Android Kotlin 中 DataStore 的基本概念以及为什么应该停止在 Android 中使用 SharedPreferences
Stored procedures and stored functions