For the naive approach of this problem, it says the runtime is O((n-k)*k).
I understand the (n-k) part but for each one, it says we do k amount of work to create the string from the array. However, don’t we also need to check if the string is in the set? If the size of the set is “s” won’t it be O(s + k)? Or are we assuming that the set is a hashtable, hence the lookup is constant?
Course: Grokking Coding Interview Patterns in JavaScript - Learn Interactively
Lesson: Solution: Repeated DNA Sequences - Grokking Coding Interview Patterns in JavaScript