学习目标:
数学
学习内容:
田田 呜呜
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;
}
};