We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The problem with this is that you are running the for loop numInputs * numInputs times, but you only really have to run the for loop numInputs + numInputs times. For example, if the grid is of size 20x20 that would mean 360 more loops than necessary.
It is a very creative idea, but it can be optimized further.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
The problem with this is that you are running the for loop numInputs * numInputs times, but you only really have to run the for loop numInputs + numInputs times. For example, if the grid is of size 20x20 that would mean 360 more loops than necessary.
It is a very creative idea, but it can be optimized further.