int maxScore(char * s){ int zeroNum=0,oneNum=0,i,total=0; int len = strlen(s); for(i=0; i<len; i++) { if(s[i] == '1') oneNum++; } for(i=0; i<len-1; i++) { (s[i] == '0') ? zeroNum++: oneNum--; if(oneNum+zeroNum > total) total = oneNum+zeroNum; } return total; }