Exit Point of a Matrix - Solution | 2-D Arrays | Data Structures and Algorithms in JAVA

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

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

  • @prashantrohilla1723
    @prashantrohilla1723 4 ปีที่แล้ว +21

    You are the best teacher, i ever found. I used to have a lot of confusions in programming. But you came as a savior and after learning from your videos, i got improved a lot and my confusions also got clear. Thank you and god bless u sir. 🙏🙏🙏🙏🙏

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว +6

      Glad I could help!!! pdhtee rhiee or share as much as you can

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

    The way of teaching is wonderful sir. I thought java is very hard but your teaching skills completely changed my mindset. A teacher like you is just a boon to me. You are the best.

  • @yogeshdixit2823
    @yogeshdixit2823 3 ปีที่แล้ว +8

    i am so happy i have solved one leet code medium problem by my own after watching this video !!!
    1041. Robot Bounded In Circle .. i submitted 100% faster java solution by my own!!
    bow down sir !!

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว +4

      Keep it up beta, aise he lge rho aur aage bdte rho.
      If you like our efforts, will you like to write a review about us here - g.page/Pepcoding/review?rc

  • @aryanverma2710
    @aryanverma2710 3 ปีที่แล้ว

    Kya baat h sir Cha gye tussi ghaint coding Haigi aap di ❤️❤️❤️❤️

  • @vaibhavsharma7410
    @vaibhavsharma7410 3 ปีที่แล้ว

    ab jaake aaya samajh.kya padhate ho sumeet sir maza aata hai coding karne mei.

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

    excellent channel to learn programming concepts

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

    Thank you so much for this solution. I came across this ques in scholarship test for pep. I tried the approach of starting traversing the matrix from where 1 is encountered and I wasn't able to complete it. This is much better. Thanks!!

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว

      Glad it helped!

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

    Great explanation!!😀😀

  • @studyhighwithlearnershub7489
    @studyhighwithlearnershub7489 3 ปีที่แล้ว +4

    Great explanation sir!!!!😃

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว

      Thanks buddy!
      If you like our efforts, will you like to review us here - g.page/Pepcoding/review?rc
      keep learning and keep loving Pepcoding😊

  • @rajatyadav747
    @rajatyadav747 2 ปีที่แล้ว

    kitna pyaara smjhaaya sir

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

    Very nice explanation !!!! Sir

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

    Aapka content lajawab hai sir

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

      share as much as you can

  • @tarunutkarsh1309
    @tarunutkarsh1309 2 ปีที่แล้ว

    Awesome sirr!!😮

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

    You're great sir

  • @aakashsharma5901
    @aakashsharma5901 3 ปีที่แล้ว

    Great explanation sir

  • @jasmeenkaur6001
    @jasmeenkaur6001 2 ปีที่แล้ว

    super explanation thank you sirrr... make more videos on greedy algorithms..

    • @Pepcoding
      @Pepcoding  2 ปีที่แล้ว

      Glad you liked it!
      Keep learning.
      And for better experience, visit nados.io, where you will get well curated content and career opportunities.

  • @mickyman753
    @mickyman753 3 ปีที่แล้ว

    kamaal h sir aap

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว

      I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
      If you like our efforts, we request a review
      g.page/Pepcoding/review?rc
      You can subscribe to our channel here
      th-cam.com/users/Pepcodingabout?view_as=subscriber

  • @shivangishukla3865
    @shivangishukla3865 3 ปีที่แล้ว

    Hmm..got it by dry run by myself later!👍

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

    Waah

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

    U won't believe I did it the same way before watching the soln 😄

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

      If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @shradhabharti4484
    @shradhabharti4484 3 ปีที่แล้ว

    well explained :)

  • @sakshiaggarwal6199
    @sakshiaggarwal6199 3 ปีที่แล้ว

    Awesome!!

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว

      Thank you! Cheers! and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

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

    does any one know what will be the time complexity?

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

    Sir isko phasa bhi toh skte h

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว

      aisa test case nahi denge.

  • @govindsinghshekhawat8533
    @govindsinghshekhawat8533 3 ปีที่แล้ว

    using character to change direction will consume less memory.

  • @pankajkr9210
    @pankajkr9210 2 ปีที่แล้ว

    What should happen if the last element in first row is "0"? is this an exit point or we go to next row?

  • @anmolgirdhar4473
    @anmolgirdhar4473 3 ปีที่แล้ว

    Come here and work hard and build the future.

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว

      wow, this cheers me up. I am glad we at pepcoding could be of help to you. Keep learning. Also, recommend us to your juniors and peers, they may also benefit.

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว

      If you like our efforts, we request a review
      g.page/Pepcoding/review?rc
      You can subscribe to our channel here
      th-cam.com/users/Pepcodingabout?view_as=subscriber
      For clearing your doubts, you can join our community on telegram
      t.me/pepcoding

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

    By learning from u it seems trivial

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

    sir this code isnot passing al the test case on geeks for geeks

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

      Possibly your code doesn't work correctly for multiple test-cases (TCs).
      The first test case where your code failed:
      Input:
      4 3
      0 1 1
      1 0 1
      1 1 1
      0 0 1
      Its Correct output is:
      2 0
      And Your Code's output is:
      0 0

    • @shashankjain4657
      @shashankjain4657 3 ปีที่แล้ว

      @@utkarshsharma6650 yes on this testacse

    • @shashankjain6774
      @shashankjain6774 3 ปีที่แล้ว

      @@shashankjain4657 hve you solved it for this case???

    • @434_utkarshsharma3
      @434_utkarshsharma3 2 ปีที่แล้ว

      @@shashankjain6774 aapko direction badalne k baad a[i][j] ko 0 karna hoga then the output will be fine

    • @simon8284
      @simon8284 2 ปีที่แล้ว

      @@434_utkarshsharma3 bhai code hi dedo nahi samja kya keh rahe ho...

  • @ankitasood8589
    @ankitasood8589 3 ปีที่แล้ว

    Sir will you please tell us a book to study all these concepts

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

    Sir execution time itna zada ku aa rha hai isme. Even for a 3×3 matrix it's taking so much time.

    • @amandixit3555
      @amandixit3555 4 ปีที่แล้ว

      try reccursion

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

      Bhai usme matrix[i][j] = 0 bhi karna tha. Agar nahi karoge toh loop mein phas jaoge.

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

    is it possible to to this question in this way
    while(row < arr.length && col < arr[0].length){
    if(arr[row][col] == 1){
    dir = ( dir + arr[row][col] ) % 4;
    }
    if(dir == 0){
    col++;
    }else if(dir == 1){
    row++;
    }else if(dir == 2){
    col--;
    }else {
    row--;
    }
    }
    System.out.println(row + " "+ col);
    }

  • @indranilchakraborty5930
    @indranilchakraborty5930 4 ปีที่แล้ว

    Gfg me ak test case me problem ho rha hai..
    3 5
    0 1 1 1 0 1 0 1 0 1 1 1 1 0 0
    Correct output:
    2 0
    Your code output:
    0 0
    Kaya gfg me galat hai??? Yea yea code galat hai...??
    Smaj nhi aah rha

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว

      Assume ki correct input dia jaega.

    • @shubhamsood1406
      @shubhamsood1406 4 ปีที่แล้ว

      Just make arr[i][j] = 0; after calculating direction otherwise it will make a circular cycle on getting 1's.

    • @rahulranjan2331
      @rahulranjan2331 4 ปีที่แล้ว

      Bro this code perfectly works...
      Only small change...you read question carefully....if 1 found change the direction and change 1 with the 0...
      So after calculating direction..
      Check ..if (arr(I,j)==1) then set the arr(I,j)=0
      And everything remain same...its work perfectly...

  • @DCHANDS
    @DCHANDS 4 ปีที่แล้ว

    sir i wasn't able to think about the approach ''dir = (dir +a[i][j])'' and perhaps that is the main reason I couldn't solve this question.
    So sir kindly evaluate me weather I should go for DS & Algo because itni choti baat me bhi dimaag nahi lga paya to aage kaise lga paunga :( Kindly Help sir

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว +3

      beta ye insight dheere dheere banti hai. khud se itni jaldi niraash na ho. 100 hour lgane ke baad sochna ki tumse hoga ya nahi

    • @DCHANDS
      @DCHANDS 4 ปีที่แล้ว

      @@Pepcoding ok sir I am positive now :) Blessed to have you sir :)

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

      Physics jaisa smjh isko jaise jee m kiya tha sb hojayega

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

      Pen copy logic bnaya kr bad m code k soch

    • @DCHANDS
      @DCHANDS 4 ปีที่แล้ว

      @@anjneykumarsingh4461 🤗

  • @LegitGamer2345
    @LegitGamer2345 4 ปีที่แล้ว

    sir i have been coding for 3+ months now and have solved many basic and easy level problems and some medium problems on gfg but still on an average it takes me 30 minutes - 1 hour to understand and implement solution of question , khud se sawaal nahi bante and sometimes ban jaate hai(rare) and sometimes even after looking at the editorial for 1+hour i am not able to understand the solution what should i do its really demotivating :(
    I am not able to solve even 5 problems per day

    • @LegitGamer2345
      @LegitGamer2345 4 ปีที่แล้ว

      i have done 280 questions on gfg but i have only covered linear data structures and sorting algos so far

    • @LegitGamer2345
      @LegitGamer2345 4 ปีที่แล้ว

      I am in first year and have not done much coding in 11th and 12th although i had IP subject in 11th and 12th in which they taught us only basics of java

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว +3

      Beta itna time to lagta he hai

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

      @@Pepcoding okay sir thank u a lot , it’s just that on the leaderboards of GFG i have seen that people are doing 20-25 problems per day so I freaked out , now that I know 30mins-1 hour is optimal , I will put more effort .

  • @RahulGupta-ki8hn
    @RahulGupta-ki8hn 3 ปีที่แล้ว +2

    someone please explain me " while(true) "

    • @bharatpipare7655
      @bharatpipare7655 3 ปีที่แล้ว

      I think you forgot to use 'break' keyword

    • @vinayjangra1401
      @vinayjangra1401 3 ปีที่แล้ว

      it means the loop will move until we break it by

  • @iffyaiyan8942
    @iffyaiyan8942 4 ปีที่แล้ว

    Sir concept to smjh a gya pr code me bar-bar compilation error a rha he aur meko smjh nhi a rha mistake kha ho rhi he, Sir mene apna code niche paste kr diya he, Aap plz ek bar dekh lijiye n
    import java.io.*;
    import java.util.*;
    public class Main {
    public static void main(String[] args) throws Exception {
    // write your code here
    Scanner scn = new Scanner(System.in);
    int n = scn.nextInt();
    int m = scn.nextInt();

    int[][] arr = new int[n][m];

    for(int i = 0; i

    • @434_utkarshsharma3
      @434_utkarshsharma3 2 ปีที่แล้ว

      haha maybe i'm late but aapne i and j ki value pehli loop k baad dobara zero nhi kari hai thats why its going out of bound

  • @ankitasood8589
    @ankitasood8589 3 ปีที่แล้ว

    Its giving wrong input for a testcase but I could not get it
    4 3
    0 1 1
    1 0 1
    1 1 1
    0 0 1
    my output - 0 0
    gfg output 2 0

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

    Kya game khele

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

    please start reactjs yourself

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

    Kaash khud hoti

  • @SCRIPTSAG
    @SCRIPTSAG 4 ปีที่แล้ว

    Sir kuch logic aisha hi socha tha lekin for loop ke bare me scoh liya nhi to mai bna deta ye sir if else mai for loop ke ander lga rha tha mai

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว

      submit krkee dekh lijiee agr submit hua tha to good nhi to refer the solution video