(牛客网)构建乘积数组
来源:互联网 发布:恺英网络王悦老婆 编辑:程序博客网 时间:2024/05/22 01:48
给定一个数组A[0,1,…,n-1],请构建一个数组B[0,1,…,n-1],其中B中的元素B[i]=A[0]A[1]…A[i-1]*A[i+1]…*A[n-1]。不能使用除法。
矩阵:
ref:来自牛客网讨论
class Solution {public: vector<int> multiply(const vector<int>& A) { vector<int> resu; int len= A.size(),t=1; resu.push_back(1); for(int i=1;i<len;i++) resu.push_back(resu[i-1]*A[i-1]); for(int i=len-2;i>=0;i--){ t*=A[i+1]; resu[i]*=t; } return resu; }};
阅读全文
0 0
- 牛客网 | 构建乘积数组
- (牛客网)构建乘积数组
- 数组------构建乘积数组
- 数组:构建乘积数组
- 构建乘积数组
- 构建乘积数组
- 52 - 构建乘积数组
- 构建乘积数组
- 构建乘积数组
- 构建乘积数组
- 构建乘积数组
- 【模模糊糊】构建乘积数组
- 构建乘积数组
- 构建乘积数组
- 构建乘积数组
- 构建乘积数组
- 构建乘积数组
- 构建乘积数组
- 【Leetcode】58. Length of Last Word
- 流程python学习笔记:第三章(2)
- 以空格为分隔符的字符串提取
- Sort
- Almost Sorted Array HDU
- (牛客网)构建乘积数组
- Qt笔记(1)连接 SQL Server 数据库
- 漠然的第一篇博客
- CMake 构建动态链接库
- IPC之—信号量
- jstl url标签
- git 使用笔记以及github注册以及创建仓库方法
- vb.net 教程 11-1 打印组件 1 基础
- Windows环境下创建动态链接库(Visual Studio版)