You are viewing a single comment's thread. Return to all comments →
This code will timeout
public static string fairRations(List B) { int count=0; bool found=false;
do{ found=false; if(B.Count < 2 || (B.Count == 2 && (B[0]%2 != B[1]%2))) { break; } for(int i=0; i<B.Count; i++) { if(B[i]%2 != 0) { found=true; B[i]+=1; if(i+1 < B.Count) { B[i+1]+=1; } else if(i-1 >=0) { B[i-1]+=1; } count+=2; break; } } }while(found); return count>0?count.ToString():"NO"; }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Fair Rations
You are viewing a single comment's thread. Return to all comments →
This code will timeout
public static string fairRations(List B) { int count=0;
bool found=false;
}