Min Li's Note
KVM,QEMU, X86 virtualization
Pages
Home
Collection
About
Tuesday, October 14, 2014
Pascal's Triangle II
Problem
Given an index k, return the kth row of the Pascal's triangle.
For example, given k = 3,
Return [1,3,3,1].
Idea
这个题目要求memory O(k)。所以只能用1维数组来做。发现row[i] = row[i]+row[i-1] 左边是下一行的row[i],右边是上一行的row[i]和row[i-1]
Solution
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment