119. Pascal’s Triangle II
My Submissions QuestionEditorial Solution
Total Accepted: 72147 Total Submissions: 224801 Difficulty: Easy
Given an index k, return the kth row of the Pascal’s triangle.

For example, given k = 3,
Return [1,3,3,1].

Note:

Could you optimize your algorithm to use only O(k) extra space?

class Solution {
public:vector<int> getRow(int rowIndex) {vector<int> v(rowIndex + 1);v[0] = 1;for(int i = 1; i <= rowIndex; i++) {v[i] = (long long int)v[i - 1] *(long long int)(rowIndex - i + 1) / i;}return v;}
};

LeetCode 119. Pascal’s Triangle II相关推荐

  1. [LeetCode]119.Pascal's Triangle II

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/SunnyYoona/article/details/43562603 题目 Given an ind ...

  2. LeetCode - Easy - 119. Pascal‘s Triangle II

    Topic Array Description https://leetcode.com/problems/pascals-triangle-ii/ Given an integer rowIndex ...

  3. leetcode python3 简单题119. Pascal's Triangle II

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第一百一十九题 (1)题目 英文: Given a non-negative ind ...

  4. 119. Pascal's Triangle II (Graph; WFS)

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...

  5. Leet Code OJ 119. Pascal's Triangle II [Difficulty: Easy]

    题目: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return ...

  6. 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 ...

  7. [LeetCode]119.Pascal#39;s Triangle II

    题目 Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [ ...

  8. LeetCode 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 ...

  9. C#LeetCode刷题之#119-杨辉三角 II(Pascal‘s Triangle II)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3690 访问. 给定一个非负索引 k,其中 k ≤ 33,返回杨辉 ...

最新文章

  1. 高速串行总线系列(1)8B/10B编码技术
  2. 【PAT乙级】1084 外观数列 (20 分)
  3. 视图插入数据_SAP Fiori的ABAP编程模型-CDS视图创建
  4. 一些PHP性能优化汇总
  5. eq linux_音乐家和音乐爱好者的开放硬件 | Linux 中国
  6. DALI调光的计算方式
  7. Postgresql之split_part()切割函数,取最后一部分
  8. 团队协作项目——SVN的使用
  9. Java--对象的克隆
  10. vue获取豆瓣图片资源,数据接口正常,图片无法显示,按右键能正常显示
  11. vscode latex 英文语法拼写检查
  12. “好好说话,别伤人。”
  13. python大学生生活信息交互平台的设计与实现毕业设计-附源码031315
  14. Qdown:你值得拥有的全功能文件下载工具
  15. JS事件监听手机屏幕触摸事件 Touch
  16. 小米AX9000安装docker的Portainer面板从社区版升级到商业版参考
  17. 工业交换机的工作原理
  18. 【计算机网络】定义、作用、特点计算机网络
  19. 虚拟机(Please umount the filesystem and rectify the problem(s))记录
  20. mt4怎么修改服务器代码,如何修改指标参数?

热门文章

  1. Linux驱动程序中的并发控制
  2. 通俗编程——白话NIO之Buffer
  3. clone oracle ebs
  4. 微软:确实存在另一枚 print spooler 0day,目前尚未修复
  5. Python连接Oracle-常见问题
  6. 高级函数技巧-函数柯里化
  7. 巨人网络305亿并购海外棋牌类游戏公司审核遭暂停
  8. 三元表达式、列表推导式、生成器表达式、递归、匿名函数、内置函数(day4)
  9. iframe页面里的链接在ios设备无法点击的解决办法
  10. 超越界限,定义未来-- HP刀片工作站WS460c Gen9无惧4K挑战