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.
O(k*log(n) + k^2*n) = O(k^2*n)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.