Skip to content

Commit

Permalink
Refactor : early return instead of any()
Browse files Browse the repository at this point in the history
  • Loading branch information
sungjinwi committed Jan 4, 2025
1 parent c2689a9 commit 563bc02
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions word-search/sungjinwi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def dfs(m: int, n: int, idx: int) -> bool:
return True

visit.add((m, n))
if any (dfs(m + r, n + c, idx + 1) \
for (r, c) in [(1, 0), (-1, 0), (0, 1), (0, -1)]):
return True
for (r, c) in [(1, 0), (-1, 0), (0, 1), (0, -1)] :
if(dfs(m + r, n + c, idx + 1)) :
return True
visit.remove((m, n))
return False

Expand Down

0 comments on commit 563bc02

Please sign in to comment.