#embody <bits/stdc++.h>
utilizing
namespace
std;
bool
examine(string s,
int
Okay,
int
restrict)
{
int
rely[2] = { 0 };
for
(
int
i = 0; i < restrict; i++) {
rely[s[i] -
'0'
]++;
}
if
(Okay >= min(rely[0], rely[1]))
return
true
;
for
(
int
i = 0; i + restrict < s.measurement(); i++) {
rely[s[i] -
'0'
]--;
rely[s[i + limit] -
'0'
]++;
if
(Okay >= min(rely[0], rely[1]))
return
true
;
}
return
false
;
}
void
clear up(string s,
int
n,
int
Okay)
{
int
Low = 1, Excessive = n;
int
ans = 0;
whereas
(Low <= Excessive) {
int
mid = Low + (Excessive - Low) / 2;
if
(examine(s, Okay, mid)) {
ans = max(ans, mid);
Low = mid + 1;
}
else
{
Excessive = mid - 1;
}
}
cout <<
"Minimal size after deletion is: "
;
int
res = n - ans;
cout << res;
}
int
most important()
{
string s =
"0110"
;
int
Okay = 2;
int
n = s.measurement();
clear up(s, n, Okay);
return
0;
}