3 ms·
> for (int i = n - 1; i >= 0; i--) { // half open Well, there's your problem right there[0]; it should be: for(size_t i = n; i-- > 0 ;) { > This is all sai
by a1369209993 6y ago
> for (int i = n - 1; i >= 0; i--) { // half open
Well, there's your problem right there[0]; it should be:
for(size_t i = n; i-- > 0 ;) {
> This is all said without even going into the awkwardness of having [k] being the {k+1}th element
You mean the awkwardness of humans using "kth" to refer to element number k-1?
0: /sarcasm
- mingodad 6y agoYour example doesn't hold water, size_t is unsigned so the test condition would never be met.
- anonymoushn 6y agoIt works. https://repl.it/repls/TanWeeOctal https://repl.it/repls/TanWeeOctal