classSolution { public: inttriangularSum(vector<int>& nums){ int n = nums.size(), size = n; queue<int> q; for(int n :nums) q.push(n); while(q.size()!=1){ int size = q.size(); int pre = q.front();q.pop(); size--; for(int i = 0;i<size; ++i){ int cur = q.front(); q.pop(); int next = cur; q.push((cur+pre)%10); pre = cur; } } return q.front(); } };