当前位置:网站首页>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
边栏推荐
- 如何開發引入小程序插件
- FBO and RBO disappeared in webgpu
- Summary of concurrency control
- Evolution of large website architecture and knowledge system
- 1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]
- Pinctrl subsystem and GPIO subsystem
- What about data leakage? " Watson k'7 moves to eliminate security threats
- Form artifact
- Recovery technology with checkpoints
- Draw a red lantern with MATLAB
猜你喜欢

实战:fabric 用户证书吊销操作流程

Recovery technology with checkpoints

微服务入门(RestTemplate、Eureka、Nacos、Feign、Gateway)

The Blue Bridge Cup web application development simulation competition is open for the first time! Contestants fast forward!

Database recovery strategy

A number of ventilator giants' products have been recalled recently, and the ventilator market is still in incremental competition

Decorator learning 01

Sentinel production environment practice (I)

Alternating merging strings of leetcode simple questions

boundary IoU 的计算方式
随机推荐
【愚公系列】2022年7月 Go教学课程 003-IDE的安装和基本使用
Search: Future Vision (moving sword)
Solutions for unexplained downtime of MySQL services
Leetcode simple question ring and rod
Shell script, awk condition judgment and logic comparison &||
Interview questions for famous enterprises: Coins represent a given value
U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程
HDU 4391 paint the wall segment tree (water
1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]
MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
Performance monitoring of database tuning solutions
How to add new fields to mongodb with code (all)
AD637 usage notes
DataGrid directly edits and saves "design defects"
Talking about MySQL index
How to view Apache log4j 2 remote code execution vulnerability?
Metaverse Ape猿界应邀出席2022·粤港澳大湾区元宇宙和web3.0主题峰会,分享猿界在Web3时代从技术到应用的文明进化历程
Database recovery strategy
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
IIC bus realizes client device