当前位置:网站首页>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
边栏推荐
- K210学习笔记(四) K210同时运行多个模型
- AD637 usage notes
- Pinctrl subsystem and GPIO subsystem
- Platformio create libopencm3 + FreeRTOS project
- Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
- 2022-07-05: given an array, you want to query the maximum value in any range at any time. If it is only established according to the initial array and has not been modified in the future, the RMQ meth
- Sparse array [matrix]
- Business learning of mall order module
- ESP32 hosted
- MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
猜你喜欢

Business learning of mall commodity module

Blocking of concurrency control

What if the files on the USB flash disk cannot be deleted? Win11 unable to delete U disk file solution tutorial

Official clarification statement of Jihu company

元宇宙中的三大“派系”

Index optimization of performance tuning methodology

笔记本电脑蓝牙怎么用来连接耳机

Pl/sql basic syntax

Two stage locking protocol for concurrency control

Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
随机推荐
Cobaltstrike builds an intranet tunnel
装饰器学习01
Sparse array [matrix]
Calculation method of boundary IOU
Database tuning solution
Interview questions for famous enterprises: Coins represent a given value
Oracle hint understanding
Form artifact
Server optimization of performance tuning methodology
Decorator learning 01
How can Bluetooth in notebook computer be used to connect headphones
微服务入门(RestTemplate、Eureka、Nacos、Feign、Gateway)
HDU 4391 paint the wall segment tree (water
Practice: fabric user certificate revocation operation process
What about data leakage? " Watson k'7 moves to eliminate security threats
The difference between MVVM and MVC
数据泄露怎么办?'华生·K'7招消灭安全威胁
Pl/sql basic case
Pl/sql basic syntax
The American Championship is about to start. Are you ready?