We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b58511 commit beb499cCopy full SHA for beb499c
src/codeTemplates/grapth.js
@@ -342,7 +342,7 @@ def topologicalSort(graph):
342
using BFS
343
"""
344
indegree = [0] * len(graph)
345
- queue = []
+ queue = collections.deque([])
346
topo = []
347
cnt = 0
348
@@ -355,7 +355,7 @@ def topologicalSort(graph):
355
queue.append(i)
356
357
while queue:
358
- vertex = queue.pop(0)
+ vertex = queue.popleft()
359
cnt += 1
360
topo.append(vertex)
361
for x in graph[vertex]:
0 commit comments