GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing raw.githubusercontent.com — raw.githubusercontent.com package com.my.test.leetcode.array;
import java.util.ArrayList;
/**
* 题目:
* pascals-triangle-ii -- newcoder 32
* 杨辉三角II -- leetcode 119
*
* 题目描述:
*
Given an index k, return the k th 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?
*
*/
public class PascalsTriangleII {
/**
* 思路:
* 1、根据杨辉三角特点(每个数是它左上方和右上方的数的和)生成元素
* 2、使用固定大小的列表缓存每行元素,从第一行开始递推下一行元素
* 3、需要缓存两个列表,一个为上一行元素,一个为本行元素,正序遍历赋值本行元素
*/
public ArrayList |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |