Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions problem_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution:
def findJudge(self, n: int, trust: List[List[int]]) -> int:
if n == 1:
return 1

indeg = [0] * (n + 1)
outdeg = [0] * (n + 1)

for a, b in trust:
outdeg[a] += 1
indeg[b] += 1

for person in range(1, n + 1):
if indeg[person] == n - 1 and outdeg[person] == 0:
return person
return -1
22 changes: 22 additions & 0 deletions problem_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from collections import deque
def hasPath(source,destiantion, maze):
Dir=[(1,0),(0,1),(0,-1),(-1,0)]
q=deque()
q.append((source))
m,n=len(maze),len(maze[0])
while(len(q)):
cord=q.popleft()
maze[cord[0]][cord[1]]=2

for d in Dir:
i,j=cord[0],cord[1]
while(-1<i<m and -1<j<n and maze[i][j]!=1):
i+=d[0]
j+=d[1]
i-=d[0]
j-=d[1]
if maze[i][j]!=2:
if i==destiantion[0] and j==destiantion[1]:
return True
q.append((i,j))
return False