Leetcode 238. Product of Array Except Self
来源:互联网 发布:闪迪固态硬盘优化软件 编辑:程序博客网 时间:2024/05/21 10:30
这里需要对累乘有比较充分的了解,那么做起来就很轻松。
class Solution {public: vector<int> productExceptSelf(vector<int>& nums) { int nums_len = nums.size(); vector<int> begin_vec(nums_len, 1); int last_seq = 1; int fst_seq = 1; for(int i = 1; i < nums_len; i++) { fst_seq *= nums[i - 1]; begin_vec[i] *= fst_seq; // begin_vec[i - 1]*nums[i - 1]; begin_vec[nums_len - i] *= last_seq; last_seq *= nums[nums_len - i]; } begin_vec[0] = begin_vec[0] * last_seq; return begin_vec; }};
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
- position定位不设置left top 等值,以及position定位的百分比取值
- Leetcode 162. Find Peak Element
- Windows 窗口与消息
- Git push提交到远程仓库卡住的问题解决
- C++多态深度剖析
- Leetcode 238. Product of Array Except Self
- [19]Window管理框架WMF(Window Management Framework) 5.0 VS Window管理框架WMF(Window Management Framework) 5.1
- 统计分析基础-描述数据
- 【李木华】队列
- csdn博客第一天 支持浏览器离线Markdown
- Git忽略文件.gitignore的使用
- Java之lambda表达式
- 51nod-1277 字符串中的最大值(KMP)
- Leetcode 442. Find All Duplicates in an Array