you are amazing ....! and few days before i saw your teaching technique its amazing after watching your video i feel very much confident and concentrate more to study. Thank you a lot for making this kind of videos.
BHIYA......YOU ARE THE BEST TEACHER EVER ...WE WILL ALWAYS TRUST YOU AND ALWAYS BE SUPPORTIVE OF YOUR BEAUTIFUL JOURNEY ......WE LOVE YOU ANUJ BHIYA...AB THO AAPKE UPPER RESPECT AUR BHED GAYA HAIN MERA.....YOU ARE JUST AMAZING ...YOU NOT ONLY GUIDE ME..BUT INSPIRE ME A LOT BHIYA. I WANT TO BECOME LIKE YOU BHIYAA...😍❤🧡 YOUR JOURNEY IS VERY MUCH INSPIRATIONAL TO US ...FROM SUPER 30 TO AMAZON ..AND A PRO-TH-camR..AND WHAT NOT.....MORE OVER YOU ARE THE BEST CREATION...THANK YOU SO MUCH FOR YOUR EFFORTS TOWARDS US....AND MAKING OUR LIVES EASY AND NOT LETTING US FACE THE SAME STRUGGLE WHICH YOU FACED ...THERE'S NO ONE LIKE YOU!!!!... I AM 2 nd YEAR STUDENT AND I AM SO HAPPY THAT I CAUGHT YOU AT RIGHT TIME. THE WAY YOU EXPLAIN EACH AND EVERYTHING IN DETAIL ...WITH YOUR BEAUTIFUL SMILE ON YOUR FACE ...KEEPS PUSHING ME AHEAD ...TO WORK MORE AND HARDER ON IT......!! I KNOW I CAN DO IT ....ALL BECAUSE OF YOU...🧡🙏🙏🙏🙏 YOU ARE MAKING THIS TH-cam PLATFORM MORE RICHER ... YOU ARE THE BEST.....WE WILL KILL IT...
class Solution { //Function to check if brackets are balanced or not. static boolean ispar(String x) { Stack st=new Stack(); st.push('a'); for(int i=0;i
your explanation is really great bhaiya. if possible ek dsa series (leetcode k questions) javascript me karao plz. I know javascript only. and javascript me dsa koi karata hi nhi.
Amazon mai job karne ke liye bohot papad bel naa padta hai...lekin aap chor diya isiliye ki aap apna Commitment pura kar sako .....bohot bura laga 😒you are great Anuj bhayia ❤️🙏
Bhaiya isme se konse algo imp hai aur konse imp nahi hai from graph mtlb konse algo must do type hai 1. bellman ford 2. Floyd warshall 3. traveling salesman 4. flood fill algo 5. graph coloring 6. snake and game 7. tarjans algo 8. kosaraju algo 9. bridge in graph 10. articulate point
Well explained!!! 😊 You told on this video that we will see what happened when there are other characters alongwith brackets but maybe you missed. Please tell me how to deal with this?
//add this line before for loop String valid = "({[]})"; //inside loop char curr = str.charAt(i); if(valid.indexOf(curr) == -1) { //you can either "return false;" or //you can ignore the character with "continue;" //you can also use both, ex: when the character is number or operator you can ignore //else you can return false //depending on the problem statement }
I have been following this amazing course! I just want to know that is there any platform where I can save all these codes and also the problems I solved in an organized way so that I can access them easily in future for revision and reference.
can we do it by two pointer method , like one from 0th index and one from nth index and keep comparing till we reach middle or we don't find right pair
@Anuj Bhaiya , Small enhancement... Can we add a condition as we know that if str.length() is odd then return false, as odd no. of brackets can't have its matches.
@@RahulVerma-on7op Yes but if its odd we ll save so much of time & memory in returning output to user, it is just one efficient condition if length is even: above logics thought in video would come, but if its odd straight away we can return false.
bhaiya meko na eak problem h main problem ko smjh kr uske solutions mind me calculte ke leta hu ki aaise aaise hona chahiye pr na code nhi likh pata kya kru!!
We can also use two increment operator count1 and count2 for the opening and closing parenthesis and atlast subtract both and if the value is zero string is valid else invalid
@anuj bhaiya Bhaiya,can u please also provide the list of most important questions related to that topic which u covered in your video so that we can do more practice by ourselves,bcz over internet there are lots of questions and I am confused that time at that which question I have to solve .so It's request to u bhaiya ,if it will be possible please do for us🙏🙏🙏🙏
First characters in the string should be open braces follwed by closed braces.. the thing is matching braces are there or not.. for example ((}} (this should be false ) I just proposed a condition of odd even it's not the full code
what if we having an input like " } ( ) { " .Based on your algorithm output is false right?.. but here they are balanced or not .In my point of view they have a pair of { } ( ).Whether my question is reachable ?..
Sir can you please make how we can make hanoi game in any language but my preferred language is PHP if you can make this video then it can help to understand.
Mujhe English bilkul nhi aati, aur me bahot jyada introvert hu, Lekin main coding me bohot achha hu, ye problem main bina stack ke 3 line of code me kr liya. Mujhe job nhi mil rhi, bolate time me atakta hu, mujhe 1 question ke bad hi interview se bahar nikal dete hai. Mujhe kuch samajh nhi aa rha, Job nhi hai aur maa bimar hai
Have three variable br1=0, br2=0, br3=0. Whenever opening bracket do respective br++ , When closing bracket do respective br-- At end check all br==0 then balanced else unbalanced.
@@harshitshukla4532 I liked this approach its very simple and efficient no need of stack also :D public static boolean checkBalance(String s) { int br1=0,br2=0,br3=0; for(int i=0;i
why not do this problem by placing a pointer at the starting of the string and one at the end and then bringing them towards the centre by iterations and comparing them at each iteration. if they don't match at any instance return false. this will take constant space and O(n) time
Python Solution: def isValid(self, s: str) -> bool: Que=[] Map={"(":")","[":"]","{":"}"} for i in s: if(i in Map): Que.append(i) else: if(len(Que)!=0 and Que[-1] in Map and Map[Que[-1]]==i): Que.pop() else: return False return len(Que)==0 #Runtime: 34 ms, faster than 31.19% of Python3 online submissions for Valid Parentheses. #Memory Usage: 14.3 MB, less than 65.11% of Python3 online submissions for Valid Parentheses.
you are amazing ....! and few days before i saw your teaching technique its amazing after watching your video i feel very much confident and concentrate more to study. Thank you a lot for making this kind of videos.
Your coding logic is very strong 💪.
Literally i am searching for this problem now and I got suggestion of these vodio
In opening(char c) method it must be checked by double equals to ==, not by single assignment operator.
right
Exceptional explanation 👏👏👏
BHIYA......YOU ARE THE BEST TEACHER EVER ...WE WILL ALWAYS TRUST YOU AND ALWAYS BE SUPPORTIVE OF YOUR BEAUTIFUL JOURNEY ......WE LOVE YOU ANUJ BHIYA...AB THO AAPKE UPPER RESPECT AUR BHED GAYA HAIN MERA.....YOU ARE JUST AMAZING ...YOU NOT ONLY GUIDE ME..BUT INSPIRE ME A LOT BHIYA. I WANT TO BECOME LIKE YOU BHIYAA...😍❤🧡 YOUR JOURNEY IS VERY MUCH INSPIRATIONAL TO US ...FROM SUPER 30 TO AMAZON ..AND A PRO-TH-camR..AND WHAT NOT.....MORE OVER YOU ARE THE BEST CREATION...THANK YOU SO MUCH FOR YOUR EFFORTS TOWARDS US....AND MAKING OUR LIVES EASY AND NOT LETTING US FACE THE SAME STRUGGLE WHICH YOU FACED ...THERE'S NO ONE LIKE YOU!!!!... I AM 2 nd YEAR STUDENT AND I AM SO HAPPY THAT I CAUGHT YOU AT RIGHT TIME. THE WAY YOU EXPLAIN EACH AND EVERYTHING IN DETAIL ...WITH YOUR BEAUTIFUL SMILE ON YOUR FACE ...KEEPS PUSHING ME AHEAD ...TO WORK MORE AND HARDER ON IT......!! I KNOW I CAN DO IT ....ALL BECAUSE OF YOU...🧡🙏🙏🙏🙏 YOU ARE MAKING THIS TH-cam PLATFORM MORE RICHER ... YOU ARE THE BEST.....WE WILL KILL IT...
No words for your compliments 🙇🙇🤗
Respect to you brother. Keep up the good work 👏
From now on I will definitely like your every video to support you as you have done same for all of us 🔥❤️
Congratulations for 500k 🎉
i found this vdo really helpful🌻🌻
Awesome brother!! So neat 👍
Sir I'm getting error as bad operand types for binary operator '||' & bad operand types for binary operator '&&' for this code
Awesome 🔥🔥🔥
Thanks a lot for the question sir
i solved it few days ago in hackerrank
Nice explanation bhaiya❤❤
Awesome video sir, really helpful
class Solution { //Function to check if brackets are balanced or not. static boolean ispar(String x) { Stack st=new Stack(); st.push('a'); for(int i=0;i
your explanation is really great bhaiya. if possible ek dsa series (leetcode k questions) javascript me karao plz. I know javascript only. and javascript me dsa koi karata hi nhi.
Thank you bhaijaan 🌟🌟🌟🌟🌟
Great!!
Thanks big bro 👍👍
Amazon mai job karne ke liye bohot papad bel naa padta hai...lekin aap chor diya isiliye ki aap apna Commitment pura kar sako .....bohot bura laga 😒you are great Anuj bhayia ❤️🙏
Thank you
Thank you so much sir
Bhaiya isme se konse algo imp hai aur konse imp nahi hai from graph
mtlb konse algo must do type hai
1. bellman ford
2. Floyd warshall
3. traveling salesman
4. flood fill algo
5. graph coloring
6. snake and game
7. tarjans algo
8. kosaraju algo
9. bridge in graph
10. articulate point
Well explained!!! 😊
You told on this video that we will see what happened when there are other characters alongwith brackets but maybe you missed. Please tell me how to deal with this?
//add this line before for loop
String valid = "({[]})";
//inside loop
char curr = str.charAt(i);
if(valid.indexOf(curr) == -1) {
//you can either "return false;" or
//you can ignore the character with "continue;"
//you can also use both, ex: when the character is number or operator you can ignore
//else you can return false
//depending on the problem statement
}
Add more questions like this🔥🔥
Please explain differences between below two:
"{ [ ] }" & "( [ ) ]"
Here both have closing so why first one is true and second is false ?
Hi, the opening and closing brackets should complement each other. Therefore, ( for ), [ for ] and { for }.
I hope you understood.
I had the same doubt, of the input string is ((]]{{[[}})).... Will this program work? Please let me know. Thanks!
thanks bhaiya
I have been following this amazing course!
I just want to know that is there any platform where I can save all these codes and also the problems I solved in an organized way so that I can access them easily in future for revision and reference.
amazing
thanks bhayi
bhaiya kya aap block chain managment pe tutorial bana skte h kya?
we need it
Anuj bhaya we can also solve this problem using Catalan numbers also right
can we do it by two pointer method , like one from 0th index and one from nth index and keep comparing till we reach middle or we don't find right pair
no not for this {}() case my bad
Here we go again
Can i write the same code for the question Write a program in ‘C’ to check for balanced parenthesis in
an expression using stack.
lot's of love to Anuj bhaiya and Love Babbar ❤️❤️❤️
@Anuj Bhaiya , Small enhancement... Can we add a condition as we know that if str.length() is odd then return false, as odd no. of brackets can't have its matches.
No. Because order also matters
@@RahulVerma-on7op Yes but if its odd we ll save so much of time & memory in returning output to user, it is just one efficient condition
if length is even: above logics thought in video would come, but if its odd straight away we can return false.
acha pahele string ka size agar odd hua toh return false kar dena sahi hoga toh ?
What If we have a problem like this “}}]]))” this code will also return true in that case because stack will be empty only ?
@Anujbhaiya abhi course complete hone me kitna time lagega....
Great
Bhai , Python ka Ek Series Banao With 150 Top Interview Problems. Which is not available in youtube in HIndi. Pura Desi bhasa mein.
May be it's personal but shashank mishra said that amazon never asked you to leave , bhaiya please clear us on this , is he lying ?
bhaiya meko na eak problem h
main problem ko smjh kr uske solutions mind me calculte ke leta hu ki aaise aaise hona chahiye
pr na code nhi likh pata
kya kru!!
Hi @anuj bhaiya , can below be considered as Balanced String
{}[(]){}
according to me no its not
Bhaiya please make a video on """how to learn Javascript"""
Bhaiyya Catalan numbers theory samjha dijiyega
We can also use two increment operator count1 and count2 for the opening and closing parenthesis and atlast subtract both and if the value is zero string is valid else invalid
This approach will fail for cases like this:
)))(((
@@AnujBhaiya hats off u bhaiya ur programming logic is excellent 🙏🙏🙏
@anuj bhaiya Bhaiya,can u please also provide the list of most important questions related to that topic which u covered in your video so that we can do more practice by ourselves,bcz over internet there are lots of questions and I am confused that time at that which question I have to solve .so It's request to u bhaiya ,if it will be possible please do for us🙏🙏🙏🙏
Bhaiya .. when the string length is even then it's true and when it's odd it's false
What about this case bro:- "(}{)"
@@jeffkirchoff14 first the opening should come na!!
First characters in the string should be open braces follwed by closed braces.. the thing is matching braces are there or not.. for example ((}} (this should be false ) I just proposed a condition of odd even it's not the full code
I doesn't mean that it's gonna be true every time when it's even
@@jeffkirchoff14 hmm... Right
Android development with kotlin course kb se aayega
what if we having an input like " } ( ) { " .Based on your algorithm output is false right?.. but here they are balanced or not .In my point of view they have a pair of { } ( ).Whether my question is reachable ?..
as parenthesis they must have a opening bracket before closing
Sir can you please make how we can make hanoi game in any language but my preferred language is PHP if you can make this video then it can help to understand.
Mujhe English bilkul nhi aati, aur me bahot jyada introvert hu,
Lekin main coding me bohot achha hu, ye problem main bina stack ke 3 line of code me kr liya.
Mujhe job nhi mil rhi, bolate time me atakta hu, mujhe 1 question ke bad hi interview se bahar nikal dete hai.
Mujhe kuch samajh nhi aa rha,
Job nhi hai aur maa bimar hai
Pls provide code in python also
First First comment to thk h Like bhe karte jao yrr video, sir itne mhnat kar rahe h or aap like bhe nai kar rahe
while writing the same code on leetcode , its showing so much errors
Open parentheses ko pop kyu jab closing parentheses aata hai to ?????
❣❤
❤❤❤❤
we can also use the logic we use in palindrome, taking two pointers, return false if not match etc. And by this was we didn't use the space. GG
Have three variable br1=0, br2=0, br3=0. Whenever opening bracket do respective br++ ,
When closing bracket do respective br--
At end check all br==0 then balanced else unbalanced.
This approach will fail for cases like these:
)(][}{
@@anujkumarsharma1013 will add an additional condition if br1= 0 and facing a closed bracket break the loop saying unbalanced...🙂
Perfect then 🙌
@@harshitshukla4532 I liked this approach its very simple and efficient no need of stack also :D
public static boolean checkBalance(String s) {
int br1=0,br2=0,br3=0;
for(int i=0;i
👍🏻👍🏻👍🏻👍🏻👍🏻👍🏻
Bhaiya, should I take a maths course for CP
No
why not do this problem by placing a pointer at the starting of the string and one at the end and then bringing them towards the centre by iterations and comparing them at each iteration. if they don't match at any instance return false. this will take constant space and O(n) time
suppose you have string like this
()(){{}()}
then in this case start and end operator will not match and give us false but actually it,s true.
Can anyone please confirm whether it is valid or not?
String str = "))XYZ(("
Leetcode program without error
class Solution {
public boolean isopening (char c){
return c =='(' || c == '{' || c == '[' ;
}
public boolean ismatching (char a,char b){
return (a =='(' && b ==')') || (a =='{' && b == '}') || (a =='[' && b == ']');
}
public boolean isValid(String s) {
Stack str = new Stack();
for ( int i = 0; i< s.length() ;i++){
char cur = s.charAt(i);
if( isopening (cur)){
str.push (cur);
}
else {
if(str.isEmpty ()) {
return false ;
}
else if (!ismatching (str.peek() ,cur)) {
return false;
}
else{
str.pop();
}
}
}
return str.isEmpty();
}
}
Helpful 👍
2nd Time...
Anuj bhaiya.. please complete this DSA one till December 2021.. I will be passing out in 2022. I am fully dependent on this course.
First
Left Amazon 🙄
beacause of this question i fail in my interview
1st year students
Is college syllabus enough to crack top MNC?
😍😍❣♥
10th comment
Python Solution:
def isValid(self, s: str) -> bool:
Que=[]
Map={"(":")","[":"]","{":"}"}
for i in s:
if(i in Map):
Que.append(i)
else:
if(len(Que)!=0 and Que[-1] in Map and Map[Que[-1]]==i):
Que.pop()
else:
return False
return len(Que)==0
#Runtime: 34 ms, faster than 31.19% of Python3 online submissions for Valid Parentheses.
#Memory Usage: 14.3 MB, less than 65.11% of Python3 online submissions for Valid Parentheses.
import java.util.*;
public class ValidParenthesis{
static boolean isParenthesisMatching(String str){
Stack s=new Stack();
for(int i=0; i
Can you please write it for c++
thankyou for this code
thank you bhaiya
Great
First