# [C (tcc)], 56 bytes <!-- language-all: lang-c --> f(int*p,int*q){for(int c=0;p-q;*p+=++c)c*=!(*p-*++p-c);} [Try it online!][TIO-kxw8popt] This is a rather straightforward port of my suboptimal [Python answer](https://codegolf.stackexchange.com/a/240429/43394). Takes a pointer to the beginning and end of the array. ## Explanation f( int *p, /* pointer to the first integer */ int *q /* pointer to the last integer */ ) { for ( int c=0; /* the increment */ p-q; /* reached the end? (if so, stop) */ /* note: these run out of order */ *p+=++c) c*=!(*p-*++p-c); /* equivalent to: int original_p0 = p[0] - c; // undo increment if (original_p0 != p[1]) { c = 0; // different, so reset counter } p[1] += c; c += 1; p += 1; // move to next p */ } [C (tcc)]: http://savannah.nongnu.org/projects/tinycc [TIO-kxw8popt]: https://tio.run/##VVDbboMgGL7nKf65bAHBRVfvqHsRZ4wBTEkcUqW7mPHZHbQaLeHj8MN3AJE4IZalxdq42LIwXsnU9kMogChSbpMrjy0tKBVExMULjm0SU2oTQfi8vGojuptUcB6d1P3H5Quh315LsIMXqDs9OjzqP1U76JRhEFRl45qyIjAh8O1@scVRGRF@L3hz2DgaCki5n86B7heUbrwj900yiNhDWFerzvwkX32bYDAjFCL8NNrgTSkUnBpdLZpRlVleedMpY7D39IHPA04e@RPmNT5@38XSisFhm522cIfvyXK226/Hg3K3wfino3n5Bw "C (tcc) – Try It Online"