当前位置:网站首页>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
边栏推荐
- 装饰器学习01
- Huawei cloud modelarts text classification - takeout comments
- 微服務鏈路風險分析
- Microservice link risk analysis
- Oracle triggers
- Depth first DFS and breadth first BFS -- traversing adjacency tables
- Database recovery strategy
- Interprocess communication in the "Chris Richardson microservice series" microservice architecture
- 微服务入门(RestTemplate、Eureka、Nacos、Feign、Gateway)
- ESP32 hosted
猜你喜欢

Index optimization of performance tuning methodology
![Sparse array [matrix]](/img/62/27b02deeeaa5028a16219ef51ccf82.jpg)
Sparse array [matrix]

database mirroring

Leetcode simple question: the minimum cost of buying candy at a discount

元宇宙中的三大“派系”

A substring with a length of three and different characters in the leetcode simple question

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

Server optimization of performance tuning methodology

Matlab draws a cute fat doll

Database recovery strategy
随机推荐
如何快速体验OneOS
Database recovery strategy
Official clarification statement of Jihu company
AD637 usage notes
How to view Apache log4j 2 remote code execution vulnerability?
CA certificate trampled pit
How to develop and introduce applet plug-ins
Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
Pl/sql basic case
Granularity of blocking of concurrency control
Cobaltstrike builds an intranet tunnel
Kubernetes Administrator certification (CKA) exam notes (IV)
Platform bus
Overview of database recovery
Learning of mall permission module
AD637使用筆記
FBO and RBO disappeared in webgpu
Shell script, awk uses if, for process control
Oracle advanced query
Leetcode simple question: find the nearest point with the same X or Y coordinate