摸鱼日记2.5
作者:互联网
学习目标:
数学
学习内容:
田田 呜呜
class Solution {
public:
int majorityElement(vector<int> &nums) {
sort(nums.begin(), nums.end());
return nums[nums.size() / 2];
}
};
田田对不起,再也不不理你打游戏了。呜呜呜
谢谢田田。
class Solution {
public:
vector<int> constructArr(vector<int> &a) {
if (a.empty())
return {};
vector<int> b;
b.resize(a.size());
b[0] = 1;
int n = a.size();
for (int i = 1; i < n; ++i) {
b[i] = b[i - 1] * a[i - 1];
}
int tmp = 1;
for (int i = n - 1; i >= 0; --i) {
b[i] *= tmp;
tmp *= a[i];
}
return b;
}
};
标签:tmp,田田,nums,int,vector,摸鱼,日记,2.5,size 来源: https://blog.csdn.net/qq_46513465/article/details/122784216