Topological Sort - Alien Dictionary (Infer Character Order)
In the following alien dictionary code snippet, which line is most likely to cause incorrect in-degree calculation leading to wrong character order?
for i in range(len(words) - 1):
word1, word2 = words[i], words[i+1]
for c1, c2 in zip(word1, word2):
if c1 != c2:
graph[c1].append(c2)
indegree[c2] += 1
break
else:
if len(word1) > len(word2):
return "" # invalid input
