package dp; import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; /** * @Author: wei1 * @Date: Create in 2018/12/24 0:48 * @Description: 这个DP难在使用O(K)的空间复杂度,从后往前覆盖dp数组,使得二位的dp数组通过覆盖达到一维 * 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 PascalTriangle {
public ArrayList