You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classSolution {
public:boolincreasingTriplet(vector<int>& nums) {
int first = INT_MAX;
int second = INT_MAX;
for (int num : nums) {
if (num <= first) {
first = num;
} elseif (num <= second) {
second = num;
} else {
returntrue;
}
}
returnfalse;
}
};
3중 반복으로 무식하게 풀면 시간초과가 나는 문제로 3가지 조건을 비교하여 한번의 반복으로 찾을 수 있다. -> 이유는 삼중 조건 자체가 선형적으로 진행되기에
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: