Evaluate Reverse Polish Notation | 2 Approaches | Leetcode 150

preview_player
Показать описание
This is the 6th Video of our Playlist "Stack  : Popular Interview Problems".In this video we will try to solve two very good Stack based problem : Evaluate Reverse Polish Notation | 2 Approaches | Leetcode 150
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases. 
Also, please note that my Github solution link below contains both C++ as well as JAVA code.

Problem Name :  Evaluate Reverse Polish Notation | 2 Approaches | Leetcode 150
Company Tags  : will update soon

Approach Summary : The algorithm iterates through the input vector of strings representing RPN expressions, pushing operands onto the stack and performing operations when encountering operators. The final result is obtained by evaluating the entire expression, and the result is returned.You can also use map to store functions for different operators

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

 Timelines
00:00 - Introduction
0:25 - Problem Explanation
4:17 - Dry Run Explanation
7:05 - Coding it up
11:26 - Using Unordered_map and Lambda
17:05 - Coding it up

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyear
Рекомендации по теме
Комментарии
Автор

How the heck this video has less views? Btw amazing tutorial thank you.

rohankadam
Автор

bohot sahi time pe video dale ho bhai.

piyushacharya
Автор

I already solved this question my own but just come here to learn your approach and i learnt something new thanks MIK.

Ankitkumar-fzkc
Автор

thank you, I learned how to write lambda function today!

bhuppidhamii
Автор

Thanks a lot bhaiya ❤❤ aaj 2nd method se kuch naya sikhne ko mila 😁

gauravbanerjee
Автор

LEARNT A LOT FROM THIS QUESTION...A BIG THANKS TO U BHAIYA🙌

oqant
Автор

what the hell yar, how less views on this video are?? it should be on top😍😍

Aimer
Автор

I forked your repo man. I am making notes from your Github repo. It's like a super resource

souravjoshi
Автор

Feeling so good that this channel is growing.

Avi-wvnb
Автор

Learnt something new (lambda wala part)
Thanks❤❤

oqant
Автор

Bro...The way you speak is very soothing to learn...thank you!!
Watching your graph playlist nowadays

saumypandey
Автор

Always Get something new with your video .

manishv.
Автор

JAVA version for Lambda approach :
class Solution {
public int evalRPN(String[] tokens) {
Stack<Integer> st = new Stack<>();
int result = 0;

Map<String, BiFunction<Integer, Integer, Integer>> mp = new HashMap<>();
mp.put("+", (a, b) -> a + b);
mp.put("-", (a, b) -> a - b);
mp.put("*", (a, b) -> (int)((long)a * (long)b));
mp.put("/", (a, b) -> a / b);

for (String s : tokens) {
if (mp.containsKey(s)) {
int b = st.pop();
int a = st.pop();

result = mp.get(s).apply(a, b);
st.push(result);
} else {
st.push(Integer.parseInt(s));
}
}
return st.pop();
}
}

wearevacationuncoverers
Автор

Thanks Sir! got to learn a new thing today.

Manash_B
Автор

i did this question, but still came to your video to see how you have done, and again you did great

satyaprakashtiwari
Автор

Learned how to write lambda for map and how to creatr a map of key, function nice

ujjawalraj
Автор

interesting tutorial broo!!
specially writing lamda

pranjalyadav
Автор

/*note lets say 8/4 hence 8 will come first in stack
and 4 will later hence hence 4 will be on top of stack lets say it is b and then 8 will be below 4 in stack lets say it is a hence
in operation we will pass(8, 4, "/")
so that it will calculate as 8/4
hence we pass a, b not as b, a
*/
order of sending a and b will matter a lot
hope it might be helpful for someone

oqant
Автор

Postfix Expressions. DS classes in BTech :)

YashSinghal
Автор

i have one doubt we are converting those values to long but when we are returning we should store them in long long but we are storing why we are not getting integer over flow

abc-ymzs