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]
.
分析 二项式展开式的系数 不加(long long)提交会出错。
class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<int> vals; vals.resize(rowIndex+);
vals[] = ; for(int i = ; i <= rowIndex;i++)
vals[i] = (long long)vals[i-]*(rowIndex-i+)/i; return vals;
}
};
119. Pascal's Triangle II的更多相关文章
- LeetCode OJ 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, ...
- 118/119. Pascal's Triangle/II
原文题目: 118. Pascal's Triangle 119. Pascal's Triangle II 读题: 杨辉三角问题 '''118''' class Solution(object): ...
- leetcode 118. Pascal's Triangle 、119. Pascal's Triangle II 、120. Triangle
118. Pascal's Triangle 第一种解法:比较麻烦 https://leetcode.com/problems/pascals-triangle/discuss/166279/cpp- ...
- 119. Pascal's Triangle II@python
Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note t ...
- [LeetCode] 119. Pascal's Triangle II 杨辉三角之二
Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note t ...
- LeetCode 119 Pascal's Triangle II
Problem: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Ret ...
- [LeetCode]题解(python):119 Pascal's Triangle II
题目来源 https://leetcode.com/problems/pascals-triangle-ii/ Given an index k, return the kth row of the ...
- leetcode 119 Pascal's Triangle II ----- java
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...
- Java [Leetcode 119]Pascal's Triangle II
题目描述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return ...
随机推荐
- MyBatis之六:缓存
MyBatis 3中的缓存实现的很多改进都已经实现了,使得它更加强大而且易于配置.默认情况下是没有开启缓存的,除了局部的session缓存,可以增强变现而且处理循环依赖也是必须的.要开启二级缓存,你需 ...
- C#中判断空字符串的3种方法性能分析
3种方法分别是:string a="";1.if(a=="")2.if(a==String.Empty)3.if(a.Length==0) 3种方法都是等效的, ...
- 调取jSon数据--展示
下面代码是将页面中的展示部分 function searchProductlistByfilterCondition(index, type, sort, filterWord) { //cite_h ...
- JavaEE系列之(一)JSP基础知识详解
一.JSP基础语法 1.JSP简介 JSP(Java Server Pages),其根本是一个简化的Servlet设计,它实现了在Java中使用HTML标签.JSP是一种动态网页 ...
- mac 功能修改。。。。
个人表示 Mac 下的 Spotlight 搜索功能确实是个鸡肋,安装 QuickSilver 才是王道!所以我个人就把 Spotlight 关闭掉了.方法很简单,还是要用到 “终端” 工具. 在 “ ...
- strassen algorithm
the explaination that is clear in my view is from wiki.
- jQuery事件之on()方法绑定多个选择器,多个事件
这样一个需求,如果用live()方法实现的话 非常简单,容易理解. $('nav li, #sb-nav li, #help li').live('click', function () { // c ...
- C#_模拟webAp_POST-GET-PUT-DELETE
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...
- [小技巧]兼容IE6的纯CSS背景半透明文字不透明
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- STOMP协议规范--转载
原文地址:http://simlegate.com/2013/10/17/stomp-specification-1.2/ 摘要 STOMP是一个简单的可互操作的协议, 被用于通过中间服务器在客户端之 ...