题解 | #构建乘积数组#
构建乘积数组
https://www.nowcoder.com/practice/94a4d381a68b47b7a8bed86f2975db46
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param A int整型vector * @return int整型vector */ vector<int> multiply(vector<int>& A) { // write code here vector<int> B; for (int i = 0; i < A.size(); ++i) { int num = 1; for (int j = 0; j < A.size(); ++j) { if (j != i) { num *= A[j]; } } B.push_back(num); } return B; } };