Back to course home
0% completed
Vote For New Content
The findIslandPerimeter implementation is wrong
Semih kekül
Sep 4, 2023
# the total should be returned not just the edge of a single island # correct implementation is below def findIslandPerimeter(matrix): rows = len(matrix) cols = len(matrix[0]) visited = [[False for i in range(cols)] for j in range(rows)] total = 0 # added for i in range(rows): for j in range(cols): if (matrix[i][j] == 1 and not visited[i][j]): total += islandPerimeterDFS(matrix, visited, i, j) # updated return total # updated
2
0
Comments
Comments
Roman Strijac2 years ago
The problem says: "The given matrix has only one island, write a function to find the perimeter of that island." but the test data has multiple islands. [[0,1,0,1,0,1,0,1,0],
[1,0,1,0,1,0,1,0,1],
[0,1,0,1,0,1,0,1,0]]
So, the solution is really for **findFIRSTIsla...
On this page