238. Product of Array Except Self
来源:互联网 发布:华南理工大学 知乎 编辑:程序博客网 时间:2024/06/01 09:27
很简单,不用除法得到结果。
class Solution {public: vector<int> productExceptSelf(vector<int>& nums) { vector<int> left2Right(nums.size(),1); vector<int> right2Left(nums.size(),1); vector<int> result; for(int i=0;i<nums.size()-1;i++) left2Right[i+1]=left2Right[i]*nums[i]; for(int i=nums.size()-1;i>0;i--) right2Left[i-1]=right2Left[i]*nums[i]; for(int i=0;i<nums.size();i++) result.push_back(left2Right[i]*right2Left[i]); return result; }};
0 0
- [leetcode] 238.Product of Array Except Self
- [LeetCode]238.Product of Array Except Self
- [leetcode] 238. Product of Array Except Self
- Leetcode 238. Product of Array Except Self
- [LeetCode]238. Product of Array Except Self
- 238. Product of Array Except Self LeetCode
- LeetCode 238. Product of Array Except Self
- 238. Product of Array Except Self
- 238. Product of Array Except Self
- 238. Product of Array Except Self
- 238. Product of Array Except Self
- [LeetCode]238. Product of Array Except Self
- 238. Product of Array Except Self
- 238. Product of Array Except Self
- 238. Product of Array Except Self
- 238. Product of Array Except Self
- LeetCode *** 238. Product of Array Except Self
- LeetCode 238. Product of Array Except Self
- Symmetric Tree
- java面向对象笔记1
- C++ STL中Map的按Key排序和按Value排序
- ssm项目的简单搭建
- CSS属性display和visibility 区别
- 238. Product of Array Except Self
- QT初学之父子窗体
- 什么时候使用静态static?
- Annotation
- POJ 3169 图论 差分约束系统
- 编译带有IORT表的UEFI
- 如何快速替换mysql数据库的某个字段的数据改为**
- CentOS 6.x 安装Google Chrome
- 9.CRM销售机会的修改和删除