<filename>SpartaCoding/week_3/dfs.py
from collections import deque
def DFS(graph,root):
    visited = []
    stack = [root]

    while stack:
        n = stack.pop()
        if n not in visited:
            visited.append(n)
            if n in graph:
                temp = list(set(graph[n]) - set(visited))
                temp.sort(reverse=True)
                stack += temp

    return "".join(str(i) for i in visited)
<filename>SpartaCoding/week_3/dfs.py
from collections import deque
def DFS(graph,root):
    visited = []
    stack = [root]

    while stack:
        n = stack.pop()
        if n not in visited:
            visited.append(n)
            if n in graph:
                temp = list(set(graph[n]) - set(visited))
                temp.sort(reverse=True)
                stack += temp

    return "".join(str(i) for i in visited)