educative.io

Explain Time complexity

Can someone explain me how is time complexity is V+N

I didn’t get how is ‘N’ coming into picture. If there are n words and combination possible is Nc2. So total number of rules is NC2?

1 Like

Even you can create N^2 edges with comparing all words with each other, only comparing adjacent words is enough for this question. We are making N-1 comparison in total . So ,we have N-1 edges.

1 Like