695. Leetcode Max Area of Island|| Code + Explanation + Example Walkthrough || June1 Daily Challenge

Поделиться
HTML-код
  • Опубликовано: 19 ноя 2024

Комментарии • 19

  • @darshandani1
    @darshandani1 2 года назад +4

    Laughed so hard when you said " Useless neighbors, we need not waste time in talking to such neighbors ". Jokes aside, Thanks for the simple and clear explanation.

  • @gouravkumarshaw5467
    @gouravkumarshaw5467 2 года назад +5

    very good explanation thanks!!!

  • @RajeshS-n2j
    @RajeshS-n2j 2 месяца назад

    cool and composed, plus nice explanation. not lot of people can present like this. 😀

  • @ANSHSINGH-zm8eu
    @ANSHSINGH-zm8eu Год назад

    class Solution {
    public:
    int areaisland(vector&grid ,int i,int j,int &count ){
    if (i>grid.size()||j>grid[0].size()||i

  • @code_clue
    @code_clue 3 года назад +2

    Well explained!! Great job. Keep it up!!

  • @himanshuamethia1160
    @himanshuamethia1160 2 года назад +1

    How to exclude water trapped inside an island ?? A slight variation to that problem

  • @devsagar5812
    @devsagar5812 Год назад

    int count_Island(vector& grid, int row, int col, int& count) {
    int m = grid.size();
    int n = grid[0].size();
    if(row < 0 || col < 0 || row >= m || col >= n || grid[row][col] == 0) {
    return 0;
    }
    // mark grid[i][j] visited as '0'
    grid[row][col] = 0;
    // check for 4 directions-> top, bottom, left, right
    if(count_Island(grid, row-1, col, count)) { // up
    count++;
    }
    if(count_Island(grid, row+1, col, count)) { // down
    count++;
    }
    if(count_Island(grid, row, col-1, count)) { // left
    count++;
    }
    if(count_Island(grid, row, col+1, count)) { // right
    count++;
    }
    return 1;
    }
    int maxAreaOfIsland(vector& grid) {
    int m = grid.size();
    int n = grid[0].size();
    int ans = INT_MIN;
    int count = 0;
    for(int i = 0; i < m; i++) {
    for(int j = 0; j < n; j++) {

    if(grid[i][j] == 1) {
    count = 1;
    count_Island(grid, i, j, count);
    }
    ans = max(ans, count);
    }
    }
    return ans;
    }

  • @IllIIIIIIllll
    @IllIIIIIIllll 2 года назад

    Neat explanation 🙌

  • @amruthaammu7463
    @amruthaammu7463 2 года назад +1

    Super b explanation

  • @foodcourt6810
    @foodcourt6810 2 года назад +1

    understood sister why are you not uploading videos nowadays?

  • @maddycoder1294
    @maddycoder1294 2 года назад

    As Usual Nice explanation

  • @sufiyaniqbal5280
    @sufiyaniqbal5280 2 года назад

    but this will not work for input of no '1' in grid

  • @meahulgupta7359
    @meahulgupta7359 3 года назад +1

    hello di please tell ki agar mai top iit me low branch leta hu toh kya mera tech company me ho jayega placement and i am not a too intelligent child i love coding

    • @code_clue
      @code_clue 3 года назад +4

      Yes, you can make it to a good company even if you are not in CS. All you need is to master data structures and algorithms. Like I have done. I was having an earth science branch (at IIT) which has nothing to do with programming yet I'm a software developer at a MnC. Hope it helps. Cheers!!

    • @foodcourt6810
      @foodcourt6810 2 года назад +3

      @@code_clue can i have ur linkedin profile?

  • @goku6272
    @goku6272 2 года назад

    Why u are not moving diagonal ??

  • @praneetsingh9695
    @praneetsingh9695 Год назад

    doesn't accept

  • @dhir_tech
    @dhir_tech 2 года назад

    best and easy explanation, thanks