---
# System prepended metadata

title: Danny
tags: [mock_interview]

---

# Danny
###### tags: `mock_interview`

```python=
# hello
# def f(s, t, node):
    
#     q = collecitons.deque()
#     used = set()
#     used.add(s)
#     q.append([s,0])
#     while len(q):
#         head = q.popleft()
#         if head[0] == t:
#             return head[1]
#         for i in node[head[0]]:
#             if i not in used:
#                 used.add(i)
#                 q.append([i, head[1]+1])
#     return -1

def f(s,t, node, gas, x):
    q = collections.deque()
    used = collections.defaultdict(int)
    used[s] = 1
    q.append([s, x])
    while len(q):
        head = q.popleft()
        if head[0] == t:
            return True
        for i in node[head[0]]:
            if used[i] < x:
                if gas[i]:
                    used[i] += 1
                    q.append([i, x])
                elif head[1] - 1 >= 0:
                    used[i] += 1
                    q.append([i, head[i]-1])
    return False

a - b - c - d - e
        |
        f


# node1 : start -> end (end contain gas)

    #nodes = {s}
    
#def findshortest
