How to express the grid in python

  • 0

    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.

  • 0

    Since one cannot do something like:

    str = '12345'

    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?

  • 0

    I converted it to list[list[char]]. It seems not slow.:

    matrix = [list(x) for x in grid]

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.