#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
//inplace solution using bit manipulation;
void gameOfLife(int** board, int rSize, int cSize)
{
for(int i = 0; i < rSize; i++)
for(int j = 0; j < cSize; j++)
{
int count = 0;
for(int rr = MAX(i1, 0); rr < MIN(i+2, rSize); rr++)
for(int cc = MAX(j1, 0); cc < MIN(j+2, cSize); cc++)
count += board[rr][cc]&1; //inplace;
count = board[i][j];
if(count==3  (board[i][j]&&count==2))
board[i][j] = 2;
}
for(int i = 0; i < rSize; i++)
for(int j = 0; j < cSize; j++)
board[i][j] >>= 1;
}
A decent, clean and inplace solution accepted as best submission in C enclosed with critical comments


This is not correct....
1.
for(int rr = MAX(i1, 0); rr < MIN(i+1, rSize); rr++) for(int cc = MAX(j1, 0); cc < MIN(j+1, cSize); cc++)
is ignoring the a row and a line when calculating count.
count = board[i][j];
shoud becount = board[i][j]&1;
to only count for current state; 
if(count==3  (board[i][j]&&count==2))
should beif(count==3  ((board[i][j]&1) &&count==2))
for the same reason.


Sorry about your first question > I really do not understand what you are trying to say;
As for the second one, the count = board[i][j] is alright here since here is board[i][j] which will only be handled once in the whole loop before <font color="#0000ff">board[i][j] = 2; </font> as for board[rr][cc] which will be essential to add board[rr][cc]&1 because this value will be handled several times;
then the third question, since second one is specified ^^
Hope this can help you!

#define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) //inplace solution using bit manipulation; void gameOfLife(int** board, int rSize, int cSize) { for(int i = 0; i < rSize; i++) for(int j = 0; j < cSize; j++) { int count = 0; for(int rr = MAX(i1, 0); rr < MIN(i+2, rSize); rr++) for(int cc = MAX(j1, 0); cc < MIN(j+2, cSize); cc++) count += board[rr][cc]&1; //inplace; count = board[i][j]; if(count==3  (board[i][j]&&count==2)) board[i][j] = 2; } for(int i = 0; i < rSize; i++) for(int j = 0; j < cSize; j++) board[i][j] >>= 1; }