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.
Interesting problem. I couldn't meet the time constraints for two of the tests in C++ and was banging my head against the wall. Changed a bunch of my STL containers to arrays and, though a little faster, still no luck. Then I realized I had my inner loop iterating over the first index and outer loop iterating over the second index in my 2d array. I simply switched the inner and outer loops and passed the time constraints easily. Will have to remember that going forward :)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tree Pruning
You are viewing a single comment's thread. Return to all comments →
Interesting problem. I couldn't meet the time constraints for two of the tests in C++ and was banging my head against the wall. Changed a bunch of my STL containers to arrays and, though a little faster, still no luck. Then I realized I had my inner loop iterating over the first index and outer loop iterating over the second index in my 2d array. I simply switched the inner and outer loops and passed the time constraints easily. Will have to remember that going forward :)