Product of Array Except Self
来源:互联网 发布:常见数据库设计 编辑:程序博客网 时间:2024/06/09 23:02
c++
class Solution {public: vector<int> productExceptSelf(vector<int>& nums) { int n = nums.size(); vector<int> res(n, 1); int left = 1, right = 1; for (int i = 0, j = n - 1; i < n - 1; ++i, --j) { left *= nums[i]; right *= nums[j]; res[i + 1] *= left; res[j - 1] *= right; } return res; }};
https://leetcode.com/discuss/94629/my-one-pass-java-solution-without-extra-spaces
0 0
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- Product of Array Except Self
- 数字阶梯求和
- C面试宝典——概念题
- typeahead/autocomplete
- 在eclipse中搭建struts2框架的详细过程
- 【贪心】NOIP2011观光公交详解
- Product of Array Except Self
- 6.3 径向基函数网络
- java字符编码转换研究
- Java实现数组的全排列
- Jsoup文档
- JSP知识小结
- C#中Image.FromFile(string path)函数报内存不足错误解决方法
- JavaScript-Array 对象及方法(上)
- myeclipse开发 spring+struts2.0+hibernate