三角相对简答题。第一个问题是太简单。我不沾了,我一定会写。其实没什么的第二个问题,与这个问题计算路径有点像一个三角形,假定输入是n,然后从第一行计数到第一n行,保存在数据线上的时间到,由于只有相关的事情跟上一行,为了防止覆盖,计数从前进或后退。

直接附着到代码:

class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<int> res(rowIndex+1) ;
if(rowIndex < 0)
return res;
res[0] = 1;
for(int i=1;i<=rowIndex;i++){
res[i] = 1;
for(int j=i-1;j>0;j--){
res[j] = res[j-1]+res[j];
}
}
return res;
}
};

版权声明:本文博客原创文章,博客,未经同意,不得转载。

leetcode先刷_Pascal&#39;s Triangle II的更多相关文章

  1. 【Leetcode】Pascal&#39;s Triangle II

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

  2. 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, ...

  3. 【一天一道LeetCode】#119. Pascal's Triangle II

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...

  4. LeetCode——Pascal&#39;s Triangle II

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

  5. [LeetCode]Pascal&#39;s Triangle II

    题目:给定一个行索引index,返回帕斯卡三角形第index层的三角形 算法:生成index层帕斯卡三角形,并返回第index层三角形 public class Solution { public L ...

  6. 【LeetCode OJ】Pascal's Triangle II

    Problem Link: http://oj.leetcode.com/problems/pascals-triangle-ii/ Let T[i][j] be the j-th element o ...

  7. Pascal&#39;s Triangle II

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

  8. 【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 [ ...

  9. LeetCode算法题-Pascal's Triangle II(Java实现)

    这是悦乐书的第171次更新,第173篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第30题(顺位题号是119).给定非负索引k,其中k≤33,返回Pascal三角形的第k ...

随机推荐

  1. PatentTips - Multi-host SATA Controller

    BACKGROUND The present subject matter relates, in general, to a computing system having multi-host p ...

  2. swift学习第七天:字典

    字典的介绍 字典允许按照某个键来访问元素 字典是由两部分集合构成的,一个是键(key)集合,一个是值(value)集合 键集合是不能有重复元素的,而值集合是可以重复的,键和值是成对出现的 Swift中 ...

  3. 安装hadoop1.2.1集群环境 分类: A1_HADOOP 2014-08-29 15:49 1444人阅读 评论(0) 收藏

    一.规划 (一)硬件资源 10.171.29.191 master 10.173.54.84  slave1 10.171.114.223 slave2 (二)基本资料 用户:  jediael 目录 ...

  4. JAVA: Socket和ServerSocket网络编程

    面是本次学习的笔记.主要分异常类型.交互原理.Socket.ServerSocket.多线程这几个方面阐述. 异常类型 在了解Socket的内容之前,先要了解一下涉及到的一些异常类型.以下四种类型都是 ...

  5. 【心情】bjdldrz

    如果我对勇士的记忆停留在73胜10负,

  6. linux下如何查找nginx配置文件的位置

    nginx的配置放在nginx.conf文件中,一般我们可以使用以下命令查看服务器中存在的nginx.conf文件. locate nginx.conf /usr/local/etc/nginx/ng ...

  7. ORA-00907: 缺失右括号问题整理解决

    ORA-00907: 缺失右括号 前言 近期在开发过程中使用oracle数据库,在程序中进行查询数据时遇到了"ORA-00907: 缺失右括号"的问题.可是假设直接把sql语句直接 ...

  8. Stacks of Flapjacks

    Stacks of Flapjacks Background Stacks and Queues are often considered the bread and butter of data s ...

  9. dot-- 资源汇总

    http://graphviz.org/doc/info/attrs.htmlhttp://graphs.grevian.org/http://graphs.grevian.org/exampleht ...

  10. ArcEngine 图层标注 (根据字段、角度)

    转自chanyinhelv原文 ArcEngine 图层标注 (根据字段.角度) 今天做了一个用AE来控制图层是否显示标注,以及已哪一个字段作为标注的字段,以哪一个字段作为标注的角度,现将代码写下来, ...