anky
BAN USERI have tested the code on a couple of inputs. If anyone found some error pls do let me know.
{
private static void FindMaxLength(int[] arr, int numberOfFlipsAllowed) {
int temp = 0, maxCount = 0, prev = 0;
int k = numberOfFlipsAllowed;
for (int i = 0; i < arr.length; i++) {
if (arr[i] == 0) {
if (k > 0) {
temp = temp + 1;
k--;
} else if (temp > maxCount) {
maxCount = temp;
temp = prev + 1;
prev = 0;
}
} else if (arr[i] == 1) {
temp++;
prev++;
}
}
System.out.println("Max Count = " + maxCount);
}}
RepOwenKary, Analyst at ASU
I am an experienced software engineer with a passion for java developing innovative programs that expedite the efficiency and effectiveness ...
RepAnaCardenas, Android Engineer at Allegient
Working as a Window clerk at EnviroSource Design for almost 10 years . Here I help people to guide . End a ...
Repdorothylopez7485, Analyst at ABC TECH SUPPORT
My name is Dorothy and I am a Host. Nowadays I am doing a new experiment like spell to keep ...
- anky February 22, 2016