re: Advent of code Day 2 Part 2 Complexity VIEW POST

VIEW PARENT COMMENT VIEW FULL DISCUSSION

This is a great idea, if I understood correctly this solution could be implemented as O(k*log(n) + k^2*n) = O(k^2*n) basically you have to do one sort for each index(meaning at most k being the length of the words) and each of those k times you can compare each of the strings with its next string, that taking O(k*n) k times and since we can assume k<<n this solves the problem. Brilliant! I will implement this ASAP.

code of conduct - report abuse