题目:
题解:
class Solution {
public:
int thirdMax(vector<int> &nums) {
int *a = nullptr, *b = nullptr, *c = nullptr;
for (int &num : nums) {
if (a == nullptr || num > *a) {
c = b;
b = a;
a = #
} else if (*a > num && (b == nullptr || num > *b)) {
c = b;
b = #
} else if (b != nullptr && *b > num && (c == nullptr || num > *c)) {
c = #
}
}
return c == nullptr ? *a : *c;
}
};