In this question, the problem gives a 2d grid map of '1's (land) and '0's (water). But I have no idea how to express it in python. Can anyone help me? thanks.
Since one cannot do something like:
str = '12345' str='a'
What I do is convert the grid from List[List[str]] to List[List[int]].
This make it slow, but I'm not sure how to make it fast. Anyone?
I converted it to list[list[char]]. It seems not slow.:
matrix = [list(x) for x in grid]