Skip to content

Instantly share code, notes, and snippets.

@tamlt2704
Created December 31, 2017 11:47
Show Gist options
  • Select an option

  • Save tamlt2704/6ab01a35214fee2f75e7659adbc9d2a1 to your computer and use it in GitHub Desktop.

Select an option

Save tamlt2704/6ab01a35214fee2f75e7659adbc9d2a1 to your computer and use it in GitHub Desktop.
#https://leetcode.com/problems/island-perimeter/description/
class Solution(object):
def islandPerimeter(self, grid):
"""
:type grid: List[List[int]]
:rtype: int
"""
return sum(sum(map(operator.ne, [0] + row, row + [0]))
for row in grid + map(list, zip(*grid)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment