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.
You load the entire data set into memory and hold it there until the end of the program, which makes a nonsense of your space efficiency claim. You traverse the data set twice - once to parse it, a second time to check the differences. The second traversal is in fact multiple traversals, since all elements other than the first two are examined at least twice.
In the queue solution described above, no input element need be evaluated more than once and no more than d elements are ever held in memory. You don't come close to that performance.
Your efficiency claims are invalid. Your code passes the test suites, but that means little since the test suites passed the inefficient code written by the puzzle setter.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Triplets
You are viewing a single comment's thread. Return to all comments →
You load the entire data set into memory and hold it there until the end of the program, which makes a nonsense of your space efficiency claim. You traverse the data set twice - once to parse it, a second time to check the differences. The second traversal is in fact multiple traversals, since all elements other than the first two are examined at least twice.
In the queue solution described above, no input element need be evaluated more than once and no more than d elements are ever held in memory. You don't come close to that performance.
Your efficiency claims are invalid. Your code passes the test suites, but that means little since the test suites passed the inefficient code written by the puzzle setter.