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.
OK, I edited my claim to be more accurate. My algorithm uses O(1) auxiliary space.
I load the entire data set into memory, but you can rewrite the same algorithm using pointers or file offsets. Three pointers use O(1) space. It certainly beats O(d) auxiliary space.
Evaluating each element up to 3 times is O(1) time each for a total of O(n) time.
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 →
OK, I edited my claim to be more accurate. My algorithm uses O(1) auxiliary space.
I load the entire data set into memory, but you can rewrite the same algorithm using pointers or file offsets. Three pointers use O(1) space. It certainly beats O(d) auxiliary space.
Evaluating each element up to 3 times is O(1) time each for a total of O(n) time.