Thankyou beta! I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem. If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
Glad to know that you liked the content and thank you for appreciating. The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos. So, keep motivating, keep learning and keep loving Pepcoding😊
Sir ek feedback hai Apka content bhot acchaa hai Sb questions ka bhot bdiya explanation hai Bs sb question m ek kami lgti hai Aap jo code krate ho uski time complexity and space complexity kese nikale vo bhi analyse kra diya kre. Uske baad koi kami nhi bachegi.
Glad you think so! 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 )
Hello sir, mera, char optor = optors.pop(); line pe error: cannot initialize a variable of type 'char' with an rvalue of type 'void' dikhara he....kaise solve karu?
Glad that you love the explanation. For better experience & well organised content visit- nados.pepcoding.com Don't forget to follow us on Instagram. instagram.com/pepcoding
There is one issue in this logic, let's say you are in the position where you get the operator and the previous item in the operator stack would not be the "(" (Closing bracket) and according your logic you get find the previous (peek) and check iterate them using while if peek have "(" then do the manupulation but if you not found then your program will fail. here is the example question: ((3+1)*2)
Hope you like the video but for better experience and well-organised content visit - nados.pepcoding.com Don't forget to follow us on Instagram instagram.com/pepcoding/
@@ronaksharma5 DS and Algo is language independent, you just see the implementation in one language and you can itself write in any, just the matter of syntax. Mai bhi java me dekh ke c me likhta hu.
Sir my right solution and even yours and editorial solution is not working on the new nados IDE please see that only 2 test cases are passing, Thank you for such nice explanations 🤟
Glad to know, that you love the explanation, for better experience and precisely arranged videos. Visit - nados.pepcoding.com and sign up to NADOS. Don't forget to follow us on Instagram instagram.com/pepcoding/
Thankyou beta! I am glad you liked it. I also hope that you are watching till the end and trying to understand the what, how, and especially why of the problem.
Hii sir, i Think we also have to check the operator presedence when character is ')' and poping until '(' i mean to say that between ( ) we also chcked the precedence of operator . right?
yes we did check the the precedence even in the () it looks like we dont but we do for eg a + (c * d / e - f) here we check precedence until f and then we see the brackets ) so we dont have to evaluate again its already checked til f i know this is not the best explanation for sure dry run and then you will realise.
sir ji me yahi code c++ me do din se bana raha hoon sala ek hi tc pass ho raha he !!! abi samaj me aayi galti apne jo tc die h apne editor me usme string me characters ke beech me spaces bi hi aur appne wo wali condition to handle ki hi nahi cpp me !!! right ???
Bro, space wali condition handle karne ki jarurat hi nhi padi kyuki koi bhi default else nhi laga. sab *if* ke (else- if) block hai. To jab bhi space aa rha hai wo kisi bhi if statement ko true nhi kar paa rha to apne aap hi next iteration pe chala jaa rha hai, jaha usse koi, digit, bracket ya operator mil rha hai.
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
what if we just write import java.io.*; import java.util.*; class name { public static void main (String[]args ) { int val= 2+(5-3*6/2); System.out.println(val); } } it will give the same output 😂😂. but thank u very mush sir , i started learning java & dsa from u only .
For better experience, visit nados.io, where you will get well curated content and career opportunities. Also, on community tab you can post your doubts.
@@Pepcoding sir ker diya but capgimini me huwa nhi kyo ki maine ye pda nhi tha nhi ab sir ache se ata hai ager rat me need me puchnge to bhi dunga etna ache se explain kiya hai sir ek bat hai sari comepny sir questions sidhe repeat ker rhi hai sir
A very small change in filling of the operand stack will sort that when you are filling that stack just check whether next element is operator or operand if operator than push in stack else keep creating the number till you have found the operator or end of string.
@@temiariyibi8505 since a number if followed by a number would mean that say we keep creating the number till the operator is not coming and when operator is there we push operatolr in operator stack and start new counter for our next number.
I literally just cried after understanding the logic,very smooth logic and very smooth code sir..
Thankyou beta!
I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
lol
Jitni taarif ki jaye utni kam hai ! What an explanation. You are the best.Thanks.
Glad to know that you liked the content and thank you for appreciating.
The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos.
So, keep motivating, keep learning and keep loving Pepcoding😊
Sir ek feedback hai
Apka content bhot acchaa hai
Sb questions ka bhot bdiya explanation hai
Bs sb question m ek kami lgti hai
Aap jo code krate ho uski time complexity and space complexity kese nikale vo bhi analyse kra diya kre.
Uske baad koi kami nhi bachegi.
hanji beta. agle saal sare questions ko redo karunga, tab karta chla jaunga.
thanks , sir i spent whole day to solve this problem before I found your video , now i am clear about this problem.
Best explanation of this problem so far 🙌
Glad you think so! 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 )
you r the best sir unfortunately got to know about ur channel a bit late but i got the best , thanku sir
1st time apka video dekha
Mast he video sir
Well understood infix expression evaluation
Legendary Explanation Of The Logic !!
How your program will solve the expression "-2+1"?
thank you sir for the wonderful explanation,always pro you are✨
Glad you liked it!
Keep learning.
And for better experience, visit nados.io, where you will get well curated content and career opportunities.
Hello sir,
mera, char optor = optors.pop(); line pe
error: cannot initialize a variable of type 'char' with an rvalue of type 'void'
dikhara he....kaise solve karu?
brother cpp me pop() void return type ka hota h, so first top() use kro then bad me pop() use kro
char optor = optors.top();
optors.pop();
amazing and best video course
Excellent would be an understatement to say for this explanation!
Glad that you love the explanation.
For better experience & well organised content visit- nados.pepcoding.com
Don't forget to follow us on Instagram. instagram.com/pepcoding
It does not handle unary operator " -1 + 4" or " -4 * 2", please suggest the edit in code that can handle these cases too.
Great Explanation!!!!!!!. Is there any video for infix evaluation for multiple digits ?
There is one issue in this logic, let's say you are in the position where you get the operator and the previous item in the operator stack would not be the "(" (Closing bracket) and according your logic you get find the previous (peek) and check iterate them using while if peek have "(" then do the manupulation but if you not found then your program will fail. here is the example question:
((3+1)*2)
No it will not be the case ..as expression is balanced and valid given in question. For ((3+1)*2) it will be working fine with o/p = 8
Any more explaination can be better than this ♥♥♥
Hope you like the video but for better experience and well-organised content
visit - nados.pepcoding.com
Don't forget to follow us on Instagram instagram.com/pepcoding/
@Pepcoding - is this question asked in any company?
What a beautiful code 🥳🥳
sir pls provide also code of solution in description box. this can also add in description box sir
Sir please provide video on implementation of stack using linked list with code in c language
Java wala ye rha
www.pepcoding.com/resources/online-java-foundation/linked-lists/linkedlist-to-stack-adapter-official/ojquestion
C mei khud bnaie
@@Pepcoding sir doubly linked list ka bhi milega ??
@@ronaksharma5 DS and Algo is language independent, you just see the implementation in one language and you can itself write in any, just the matter of syntax. Mai bhi java me dekh ke c me likhta hu.
Thanks for amazing explanation . whats the time comp. ?
O(n)
isn't it we need store result in double. for example 3 / 2 = 1. will cause type casting issue
Thank you very much. understood in one go🙏
i did on my own but i think with the same logic like you but instead of 2 i was managing the only one stack
can we use the same logic for an expression with multiple-digit numbers ?
no it won't work.
Sir my right solution and even yours and editorial solution is not working on the new nados IDE please see that only 2 test cases are passing, Thank you for such nice explanations 🤟
Glad to know, that you love the explanation, for better experience and precisely arranged videos.
Visit - nados.pepcoding.com and sign up to NADOS.
Don't forget to follow us on Instagram instagram.com/pepcoding/
is this question available on leetcode
Fabulous explanation brother! Thank you!
Thank you so much Bhai. Keep learning, Keep growing and keep loving Pepcoding!😊
absolute legend!
Thankyou beta!
I am glad you liked it. I also hope that you are watching till the end and trying to understand the what, how, and especially why of the problem.
@@Pepcoding yes sir, I understood it very well. Also implemented by myself. Thank you ❤️.
Hii sir, i Think we also have to check the operator presedence when character is ')' and poping until '('
i mean to say that between ( ) we also chcked the precedence of operator . right?
yes we did check the the precedence even in the () it looks like we dont but we do for eg a + (c * d / e - f) here we check precedence until f and then we see the brackets ) so we dont have to evaluate again its already checked til f
i know this is not the best explanation for sure dry run and then you will realise.
sir ji me yahi code c++ me do din se bana raha hoon sala ek hi tc pass ho raha he !!! abi samaj me aayi galti apne jo tc die h apne editor me usme string me characters ke beech me spaces bi hi aur appne wo wali condition to handle ki hi nahi cpp me !!! right ???
if you want the test cases, i can share them
Hey bro for handling space while cin use getline.
Bro, space wali condition handle karne ki jarurat hi nhi padi kyuki koi bhi default else nhi laga. sab *if* ke (else- if) block hai. To jab bhi space aa rha hai wo kisi bhi if statement ko true nhi kar paa rha to apne aap hi next iteration pe chala jaa rha hai, jaha usse koi, digit, bracket ya operator mil rha hai.
can you pls share your code to me
use
getline(cin, str) for taking input
awesome explanation!!!!!!!
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
sir this is wonderful
Thanks a lot :) For more such content with a better user experience visit nados.pepcoding.com
answer is not submitting showing server error
PepCoding server is shut down.
@@Pepcoding when it start sir ?
shut down for ever.
@@Pepcoding ok sir😞😓. thankyou for this wonderfull playlist.
@@Pepcoding sir please open kijiye server firse
Iss Code ko C language main kaise likh Sakte hain
what if we just write
import java.io.*;
import java.util.*;
class name
{
public static void main (String[]args )
{
int val= 2+(5-3*6/2);
System.out.println(val);
}
}
it will give the same output 😂😂.
but thank u very mush sir , i started learning java & dsa from u only .
For better experience, visit nados.io, where you will get well curated content and career opportunities.
Also, on community tab you can post your doubts.
Gajab Bhai 😂😂
itna bdha code kese kr liaa bhai
Same question asked in capgimini 6.8 lkhs ke liye but students can't solve this question
If you like my efforts, I request a review
g.page/Pepcoding/review?rc
@@Pepcoding sir ker diya but capgimini me huwa nhi kyo ki maine ye pda nhi tha nhi ab sir ache se ata hai ager rat me need me puchnge to bhi dunga etna ache se explain kiya hai sir ek bat hai sari comepny sir questions sidhe repeat ker rhi hai sir
@@farazahmad9734 bhai 1000 question ker lega to bhai sari company whi question puchti hai amezon also wo bnayenge thodi na question
I just realised that this holds good for only single-digit integers. This fails for other cases.
A very small change in filling of the operand stack will sort that when you are filling that stack just check whether next element is operator or operand if operator than push in stack else keep creating the number till you have found the operator or end of string.
@@akshatgoyal9113 How would this be implemented? Please respond 🙏🏾
@@temiariyibi8505 since a number if followed by a number would mean that say
we keep creating the number till the operator is not coming and when operator is there we push operatolr in operator stack and start new counter for our next number.
yes sir sun rhe han
thanks
Keep on learning.
And for better experience and well organised content visit nados.pepcoding.com
perfectooooooooooooooo
aakhir 1 ghata lagaka ho hee gayyaa sawalll
keep motivating, keep learning and keep loving Pepcoding😊
answer is -2 . 😊
Glad you liked it!
Keep learning.
And for better experience, visit nados.io, where you will get well curated content and career opportunities.
//Source Code:
package com.soham.PrepCoding; //This line can be ignored
import java.util.Scanner;
import java.util.Stack;
public class InfixEvaluation {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s= sc.nextLine();
Stackoperands=new Stack();
Stackoperator=new Stack();
for (int i = 0; i < s.length(); i++) {
char ch=s.charAt(i);
if(ch=='('){
operator.push(ch);
}else if(Character.isDigit(ch)) {
operands.push(ch - '0');
}else if(ch==')'){
while(operator.peek()!='('){
char opr=operator.pop();
int v2=operands.pop();
int v1=operands.pop();
int opVal= operation(v1,v2,opr);
operands.push(opVal);
}
operator.pop();
}else if(ch=='+' || ch=='-' || ch=='*' || ch=='/'){
while(operator.size()>0 && operator.peek()!='(' && precedence(ch)
For best experience and precisely arranged content visit on nados.io, even you can solve your doubts by posting it on community tab on NDAOS
Im getting output 6/3-1 is 0
How your program will solve the expression "-2+1"?