Number of Enclaves - Leetcode 1020 - Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 พ.ย. 2024

ความคิดเห็น • 26

  • @vishnuvardhan2687
    @vishnuvardhan2687 ปีที่แล้ว +2

    He is a king 👑👑👑 of coding

  • @moonlight-td8ed
    @moonlight-td8ed 5 หลายเดือนก่อน +1

    did my own, by watching your video on surrounded region(dfs) thank you

  • @lessw2020
    @lessw2020 ปีที่แล้ว +1

    Great video as usual. One comment, your code font size is tiny in this one vs usual ones.

  • @zagenX
    @zagenX ปีที่แล้ว

    Thanks! help to see how own solution can be improved :)

  • @nikhilgoyal007
    @nikhilgoyal007 ปีที่แล้ว

    line #12 -> res = 1 : would this not set res = 1 again for each dfs call (instead of adding to the initial 1)

  • @krateskim4169
    @krateskim4169 ปีที่แล้ว

    Thank you so much

  • @mrmcpherson2722
    @mrmcpherson2722 ปีที่แล้ว

    The notification I wanted to see

  • @VladiqLot
    @VladiqLot ปีที่แล้ว

    Python are beautiful!

  • @isma5627
    @isma5627 ปีที่แล้ว

    what a beutiful solution!

  • @arkhopravosarkar494
    @arkhopravosarkar494 ปีที่แล้ว

    Thankyou❤

  • @cc-to2jn
    @cc-to2jn ปีที่แล้ว

    Heres a solution following his usual pattern:
    count=0
    visited=set()
    def bfs(i,j):
    nonlocal count
    if (i

  • @raginibhayana8305
    @raginibhayana8305 ปีที่แล้ว +2

    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?

    • @arjunsharma9676
      @arjunsharma9676 ปีที่แล้ว

      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

    • @mohammedajmal4264
      @mohammedajmal4264 ปีที่แล้ว +1

      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

    • @acceleratorlevel645
      @acceleratorlevel645 ปีที่แล้ว

      we surely can use yesterday's approach to solve this as well, just need to make a few changes in the dfs

    • @raginibhayana8305
      @raginibhayana8305 ปีที่แล้ว

      Yup, I have solved it. I attached my solution link but I think links are blocked on comments.

    • @mohammedajmal4264
      @mohammedajmal4264 ปีที่แล้ว +1

      @@raginibhayana8305 nice 👌

  • @roach5429
    @roach5429 ปีที่แล้ว

    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?

    • @adityarawat3670
      @adityarawat3670 ปีที่แล้ว

      In case 2 we have 4 total land and 4 border land so land-borderland will give zero

  • @akshadabhandari
    @akshadabhandari ปีที่แล้ว

    I am failing test cases like even if grid[r][c] == 1: its going in the if condition and returning 0

  • @DeathSugar
    @DeathSugar ปีที่แล้ว

    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

  • @aryannargotra
    @aryannargotra หลายเดือนก่อน

    Unable to open the website

  • @vishnuvardhan2687
    @vishnuvardhan2687 ปีที่แล้ว +1

    Aliens 👽👽 attendance taken here

  • @shubhampathak7926
    @shubhampathak7926 ปีที่แล้ว

    Can you put the difficulty level of problems on thumbnail?

  • @harshitpant07
    @harshitpant07 ปีที่แล้ว

    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