Great approach🔥. Another approach is we can find number of common sides of cell. If there are x cells with 1 and y sides are common. Then answer will be 4*x-2*y Because single common side is attached to 2 cells. Below is my python code: class Solution: def islandPerimeter(self, grid: List[List[int]]) -> int: common=0 count=0 for i in range(len(grid)): for j in range(len(grid[0])): count+=grid[i][j] if(i+1
my solution : class Solution { public: int islandPerimeter(vector& grid) { int n = grid.size(); int sum= 0 ; int temp =0; for(int i=0;i0 && grid[i-1][j]==1) temp-=1; if(i
Great approach🔥. Another approach is we can find number of common sides of cell.
If there are x cells with 1 and y sides are common.
Then answer will be
4*x-2*y
Because single common side is attached to 2 cells.
Below is my python code:
class Solution:
def islandPerimeter(self, grid: List[List[int]]) -> int:
common=0
count=0
for i in range(len(grid)):
for j in range(len(grid[0])):
count+=grid[i][j]
if(i+1
Hey bro! Start making videos of Codeforces Contests alsoo...
keep up the good work
my solution : class Solution {
public:
int islandPerimeter(vector& grid) {
int n = grid.size();
int sum= 0 ;
int temp =0;
for(int i=0;i0 && grid[i-1][j]==1)
temp-=1;
if(i
Solve this
verifying an alien dictionary leedcode problem
camera kaha gya aaj?😅