Skip to content

Instantly share code, notes, and snippets.

@aakashns
Created June 19, 2012 21:43
Show Gist options
  • Save aakashns/2956711 to your computer and use it in GitHub Desktop.
Save aakashns/2956711 to your computer and use it in GitHub Desktop.
Optimized Code for 1's and 0's
int diff = 0;
for (int i = 0; i <= n; i++){
if (B[diff + n] == -1) B[diff + n] = i;
else C[diff + n] = i;
if (A[i]) diff++; else diff--;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment