标签:png for 面试 public color cto struct ret idt
题目:
解答:
1 class Solution { 2 public: 3 vector<int> constructArr(vector<int>& a) 、 4 { 5 int n = a.size(); 6 vector<int> ret(n, 1); 7 8 int left = 1; 9 for (int i = 0; i < n; i ++) 10 { 11 ret[i] = left; 12 left = left * a[i]; 13 } 14 15 int right = 1; 16 for (int i = n-1; i >= 0; i --) 17 { 18 ret[i] *= right; 19 right *= a[i]; 20 } 21 return ret; 22 } 23 };
标签:png for 面试 public color cto struct ret idt
原文地址:https://www.cnblogs.com/ocpc/p/12859896.html