1901-1910¶
1911-1920¶
1921-1930¶
1931-1940¶
1941-1950¶
1951-1960¶
1961-1970¶
1971-1980¶
class Solution {
public:
int GCD(int a, int b) {
return b ? GCD(b, a % b) : a;
}
int findGCD(vector<int> &nums) {
int min = nums[0], max = nums[0];
for (auto &it: nums) {
min = it < min ? it : min;
max = it > max ? it : max;
}
return GCD(min, max);
}
};
1981-1990¶
1991-2000¶
class Solution {
public:
int findMiddleIndex(vector<int> &nums) {
int total = accumulate(nums.begin(), nums.end(), 0);
for (int i = 0, sum = 0; i < nums.size(); i++) {
if (sum == total - nums[i] - sum)
return i;
else
sum += nums[i];
}
return -1;
}
};