We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行。
在杨辉三角中,每个数是它左上方和右上方的数的和
Input: 3 Output: [1,3,3,1]
O(k)
The text was updated successfully, but these errors were encountered:
/** * @param {number} rowIndex * @return {number[]} */ var getRow = function(rowIndex) { const reuslt = new Array(rowIndex + 1); for (let i = 0; i <= rowIndex; i++) { for (let j = i; j >= 0; j--) { if (j === i || j === 0) { reuslt[j] = 1; } else { reuslt[j] = reuslt[j] + reuslt[j - 1]; } } } return reuslt; };
function getRow(rowIndex: number): number[] { const reuslt: number[] = new Array(rowIndex + 1); for (let i = 0; i <= rowIndex; i++) { for (let j = i; j >= 0; j--) { if (j === i || j === 0) { reuslt[j] = 1; } else { reuslt[j] = reuslt[j] + reuslt[j - 1]; } } } return reuslt; };
Sorry, something went wrong.
No branches or pull requests
119. Pascal's Triangle II
给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行。
在杨辉三角中,每个数是它左上方和右上方的数的和
Example
Follow up
O(k)
空间复杂度吗?The text was updated successfully, but these errors were encountered: