[leetcode]238. Product of Array Except Self
来源:互联网 发布:php swoole 编辑:程序博客网 时间:2024/06/14 11:39
//算法思想是先求出i 之前的所有乘积,再求出i 之后的所有乘积,两者之积就是i的值class Solution {public: vector<int> productExceptSelf(vector<int>& nums) { int n=nums.size(); vector<int> product(n,0); if(nums.size()>0) { product[0]=1; for(int i=1;i<n;i++) { product[i]=(nums[i-1]*product[i-1]); } nums.push_back(1); for(int i=n-1;i>=0;i--) { nums[i]=nums[i]*nums[i+1]; product[i]=product[i]*nums[i+1]; } } return product; }};
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
- [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
- 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
- leetcode:238. Product of Array Except Self
- Jstl自定义标签及其生命周期、属性标签、及其读取文本练习、JspFragment输出标签体(2)
- Android onTouch以及onTouchEvent触屏事件的分析
- spring自动扫描
- javamail邮件发送小案例
- Pegasus间谍套件内部原理及流程剖析
- [leetcode]238. Product of Array Except Self
- Function的一些属性
- 数据结构之链表:实现单链表的逆序 (1)
- in和delete运算符
- Spring boot 在ubuntu 上启动缓慢
- Integer类型的对象相等的问题
- Redis的使用
- jQuery的选择器
- 面向对象设计原则之四:依赖倒置原则