【LeetCode】238. Product of Array Except Self
来源:互联网 发布:淘宝会员怎么注册 编辑:程序博客网 时间:2024/06/03 21:04
题解:主要用两指针的思想,左指针用来记录左边数的乘积右指针用来记录右边数的乘积并且同时计算左右两边的乘积
vector<int> productExceptSelf(vector<int>& nums) { int n=nums.size(); int l=1,r=1; vector<int> res(n,1); for(int i=0;i<n;i++) { res[i]*=l; l*=nums[i]; res[n-i-1]*=r; r*=nums[n-i-1]; } return res;}
阅读全文
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
- 【LeetCode】136 Single Number
- 1.8 C# 继承和继承关系中的构造函数
- python day05 编写一个给定多项式的简易计算机 re模块及正则匹配应用
- JavaScript数据类型
- Leetcode 650. 2 Keys Keyboard 2指键盘 解题报告
- 【LeetCode】238. Product of Array Except Self
- Python3笔记-廖雪峰
- React 如何阻止事件冒泡?
- JavaScript
- Java 数组的插入排序
- Cookie/Session机制详解
- JAVASE基础(八)
- LOJ6212-「美团 CodeM 决赛」melon
- CSS变量variable