3 ms·
To be symmetric, the loops should read like this: for (i = 0; i < n; i++) for (i = n; --i >= 0; ) The second one could also be this: for (i = n - 1; i
by trealira 2y ago
To be symmetric, the loops should read like this:
for (i = 0; i < n; i++)
for (i = n; --i >= 0; )
The second one could also be this:
for (i = n - 1; i >= 0; i--)
I say this because your backwards loop accesses the inclusive range [0, n] while your forwards range accesses [0, n - 1].