Sign in

Let’s jump in.
You are using an array in your code, and you want to set it all to one value.

I’m going to use a C/C++ syntax here.
The trivial way is:

int A[100];
for (int i = 0; i < 100; i++)
A[i] = 0;

Very nice and clean. The problem? it takes too much time!
Well maybe the above code doesn’t, but this one:

int A[100000000];
for (int i = 0; i < 100000000; i++)
A[i] = 0;

You are not convinced yet? How about a program that does it in a loop?

int A[100000000];for (int…

Tom Herman

CS master's student at the Technion, Israel

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store