Memset slower than iterating ?? (TWTCLOSE)

I recently submitted the solution for TWTCLOSE . I have used memset to set all values of a boolean array to false… But when I replaced memset with a standard loop over all the values…The running time for the program surprisingly got reduced when using the loop (By 0.01 seconds)

Here are my two submissions

What can be the reasons?

I don’t think it’s a memset issue. Some times the program runs a bit slower due to other processing like overhead, clearing cache. In one problem i also submitted the same exact code twice and got 0.05 sec of difference. So, surprisingly it’s not the memset issue it’s processing issue.

1 Like

Such comparison is like saying “My dice always shows 6, I rolled it once and it showed 6.”…

1 Like