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
从左扫一遍,累乘得到一个left数组
从右扫一遍,累乘得到一个right数组
把nums [ i ] 的left [ i -1 ] * right [ i +1 ]得到答案数组
var productExceptSelf = function (nums) { let left = [1] for (let i = 0; i < nums.length; i++) { left[i + 1] = left[i] * nums[i] } left.push(1) let right = [1] right[nums.length + 1] = 1 for (let i = nums.length; i > 0; i--) { right[i] = right[i + 1] * nums[i - 1] } let res = [] for (let i = 0; i < left.length - 2; i++) { res[i] = left[i] * right[i + 2] } return res }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
238-除自身以外数组的乘积
我的思路
从左扫一遍,累乘得到一个left数组
从右扫一遍,累乘得到一个right数组
把nums [ i ] 的left [ i -1 ] * right [ i +1 ]得到答案数组
代码实现
The text was updated successfully, but these errors were encountered: