When I look at part “b”, I see outer and inner for loops, where we compare words until we compare different characters.
It seems to me that in the worst case, the time complexity of that part will be O (N * length of the longest word).
This concludes to O (N * L), where L is the length of the longest word.
So my question is why the time complexity is only taking into consideration part “d” of the algorithm, i.e. O (V + N), and not the time complexity of part “b”?
Thanks