i am trying to solve this question using yesterdays technique in which i am calculating the number of land not touching the water. can you please help me with that?
we can use yesterday's technique but in yesterday's problem we were counting the no.of areas containing and today we have to count the cells in that particular area
import sys sys.setrecursionlimit(1000000000) from typing import List class Solution: def numberOfEnclaves(self, grid: List[List[int]]) -> int: # code here def dfs(i, j): grid[i][j] = 0 for x, y in (i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1): if 0
He is a king 👑👑👑 of coding
did my own, by watching your video on surrounded region(dfs) thank you
Great video as usual. One comment, your code font size is tiny in this one vs usual ones.
Thanks! help to see how own solution can be improved :)
line #12 -> res = 1 : would this not set res = 1 again for each dfs call (instead of adding to the initial 1)
Thank you so much
The notification I wanted to see
Python are beautiful!
what a beutiful solution!
Thankyou❤
Heres a solution following his usual pattern:
count=0
visited=set()
def bfs(i,j):
nonlocal count
if (i
i am trying to solve this question using yesterdays technique in which i am calculating the number of land not touching the water. can you please help me with that?
Here is my solution -
class Solution {
public int numEnclaves(int[][] grid) {
int count=0;
int m= grid.length;
int n=grid[0].length;
for(int i=0;i
we can use yesterday's technique but in yesterday's problem we were counting the no.of areas containing and today we have to count the cells in that particular area
we surely can use yesterday's approach to solve this as well, just need to make a few changes in the dfs
Yup, I have solved it. I attached my solution link but I think links are blocked on comments.
@@raginibhayana8305 nice 👌
I dont get how this approach work for example 2. we have 4 lands ans 2 lands are on border so shouldn't this code return 2 instead of 0?
In case 2 we have 4 total land and 4 border land so land-borderland will give zero
I am failing test cases like even if grid[r][c] == 1: its going in the if condition and returning 0
lol, every time I upload my solution in rust and see something over 1ms feels sus. And than I see python solutions run at almost 1s
Unable to open the website
Aliens 👽👽 attendance taken here
Can you put the difficulty level of problems on thumbnail?
import sys
sys.setrecursionlimit(1000000000)
from typing import List
class Solution:
def numberOfEnclaves(self, grid: List[List[int]]) -> int:
# code here
def dfs(i, j):
grid[i][j] = 0
for x, y in (i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1):
if 0