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:intlongestSubarray(vector<int>& nums) {
int left = 0;
int max_len = 0;
int zero_count = 0;
for (int right = 0; right < nums.size(); right++) {
if (nums[right] == 0) {
zero_count++;
}
while (zero_count > 1) {
if (nums[left] == 0) {
zero_count--;
}
left++;
}
max_len = max(max_len, right - left);
}
return max_len;
}
};
슬라이딩 윈도우을 사용함 전 문제랑 비슷하게 품
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: