Episode 23 – Number of Islands

The Code Snippets Podcast
The Code Snippets Podcast
Episode 23 - Number of Islands
/

Today I talk about another Leetcode problem

https://leetcode.com/problems/number-of-islands/

Please review my podcast at https://thecodesnippetspodcast.com/feedback

grid = [
    ["1","1","1","1","0"],
    ["1","1","0","1","0"],
    ["1","1","0","0","0"],
    ["0","0","0","0","0"]
  ]



# Number of Y axies

y = grid.count()

# Number of X axies
x = grid[0].count()

# Print out grid

(0..y-1).each do |y2|
    (0..x-1).each do |x2|
        print grid[y2][x2]
    end
    puts
end