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. 🙏🙏🙏🙏🙏
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.
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 !!
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
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!!
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
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 )
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 )
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.
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
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
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); }
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
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...
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
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
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 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 .
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();
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. 🙏🙏🙏🙏🙏
Glad I could help!!! pdhtee rhiee or share as much as you can
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.
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 !!
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
Kya baat h sir Cha gye tussi ghaint coding Haigi aap di ❤️❤️❤️❤️
ab jaake aaya samajh.kya padhate ho sumeet sir maza aata hai coding karne mei.
excellent channel to learn programming concepts
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!!
Glad it helped!
Great explanation!!😀😀
Great explanation sir!!!!😃
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😊
kitna pyaara smjhaaya sir
Very nice explanation !!!! Sir
Aapka content lajawab hai sir
share as much as you can
Awesome sirr!!😮
You're great sir
aap bhi
Great explanation sir
super explanation thank you sirrr... make more videos on greedy algorithms..
Glad you liked it!
Keep learning.
And for better experience, visit nados.io, where you will get well curated content and career opportunities.
kamaal h sir aap
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
Hmm..got it by dry run by myself later!👍
Waah
U won't believe I did it the same way before watching the soln 😄
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 )
well explained :)
Awesome!!
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 )
does any one know what will be the time complexity?
Sir isko phasa bhi toh skte h
aisa test case nahi denge.
using character to change direction will consume less memory.
What should happen if the last element in first row is "0"? is this an exit point or we go to next row?
its an exit
Come here and work hard and build the future.
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.
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
By learning from u it seems trivial
sir this code isnot passing al the test case on geeks for geeks
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
@@utkarshsharma6650 yes on this testacse
@@shashankjain4657 hve you solved it for this case???
@@shashankjain6774 aapko direction badalne k baad a[i][j] ko 0 karna hoga then the output will be fine
@@434_utkarshsharma3 bhai code hi dedo nahi samja kya keh rahe ho...
Sir will you please tell us a book to study all these concepts
CLRS
@@utkarshsharma6650 CLRS?
@@ankitasood8589 google it
Sir execution time itna zada ku aa rha hai isme. Even for a 3×3 matrix it's taking so much time.
try reccursion
Bhai usme matrix[i][j] = 0 bhi karna tha. Agar nahi karoge toh loop mein phas jaoge.
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);
}
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
Assume ki correct input dia jaega.
Just make arr[i][j] = 0; after calculating direction otherwise it will make a circular cycle on getting 1's.
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...
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
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
@@Pepcoding ok sir I am positive now :) Blessed to have you sir :)
Physics jaisa smjh isko jaise jee m kiya tha sb hojayega
Pen copy logic bnaya kr bad m code k soch
@@anjneykumarsingh4461 🤗
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
i have done 280 questions on gfg but i have only covered linear data structures and sorting algos so far
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
Beta itna time to lagta he hai
@@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 .
someone please explain me " while(true) "
I think you forgot to use 'break' keyword
it means the loop will move until we break it by
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
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
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
Kya game khele
please start reactjs yourself
Kaash khud hoti
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
submit krkee dekh lijiee agr submit hua tha to good nhi to refer the solution video