MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / is_safe

Function is_safe

matrix/max_area_of_island.py:21–30  ·  view source on GitHub ↗

Checking whether coordinate (row, col) is valid or not. >>> is_safe(0, 0, 5, 5) True >>> is_safe(-1,-1, 5, 5) False

(row: int, col: int, rows: int, cols: int)

Source from the content-addressed store, hash-verified

19
20
21def is_safe(row: int, col: int, rows: int, cols: int) -> bool:
22 """
23 Checking whether coordinate (row, col) is valid or not.
24
25 >>> is_safe(0, 0, 5, 5)
26 True
27 >>> is_safe(-1,-1, 5, 5)
28 False
29 """
30 return 0 <= row < rows and 0 <= col < cols
31
32
33def depth_first_search(row: int, col: int, seen: set, mat: list[list[int]]) -> int:

Callers 1

depth_first_searchFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected