After seeing this problem I definitely knew that it would be a recursive solution. However, I could not visualize the recursion for this problem which made it super tough for me. But thanks to MIK, now it's become super easy to understand.
Hello MIK first of all I want to thank you for your amazing teaching skill, the way you taught its really amazing.❤❤❤❤❤❤❤❤ and could you please tell what software you are using to teach us , it will really help me to take notes ❤❤
class Solution { public List diffWaysToCompute(String exp) { return solve(0,exp.length()-1,exp); } public List solve(int stIdx,int endIdx,String exp){ List list=new ArrayList(); for(int i=stIdx;i
when i was trying to come up with an idea the ideas i had was of using a stack of sorts and I realised ki that wont be feasible the other was about maybe storing it as expression trees and all, again was too complex lol idk fi thats right even
I created separate array for numbers and operators Very similar to Unique BST 2 class Solution { public: vector numbers; vector op; map mp; vector solve(int l, int r){ if(l == r) { return {numbers[l]}; } if(mp.find({l , r}) != mp.end()){ return mp[{l , r}]; } vector res; for(int i=l;i
Bhaiya I dont understand how result.push_back(x + y) is pushing an integer in the array as we didnt convert it to int cuz last case will only work if the whole string doesnt contain any operator plz help
bro don't be sad, I will make it crystal clear for you 🙂 Basically, for any expression, the base case will be an expression without any operator , cuz we keep Splitting the expression whenever we are seeing operator so obv. at the end, it will be an expression without any operator. Since There will be No operator at the base, WE WILL NOT GO INTO THE LOOP and Return The Expression (no operand will be there) in the form INT (using stoi) to the Result Vector and It will be Returned to 'Left-Result' or 'Right - Result' Vector, Hence We Will Be Getting Vector of INT.
Pehele question mein all possible ways keyword dekh Kar mere dimag mein backtracking aaya tha, fir koi approach nehi aaya dimag mein, to topics tag dekha woha dp tha par mujhe dp nehi aata, isiliye solve nehi hua, and options nehi samajh ayya question mein to recursion se kyese hoga ye bhi nehi hua. So solved after watching explanation and approach. How to find options from a recursion based question? Pls say bhaiya
Hello MIK bhai, I’m new to your channel and I saw great response from people watching you. I have always faced difficulties in Dsa like understanding the concept and problem related to it is not the tougher job but whenever I’ve tried solving on my own it just doesn’t happen to be. I’m requesting you to provide a sheet/combined playlist starting from basic concepts and their problems to slowly climbing the difficulty ladder to advance or med-hard problems. Please take this into consideration 🥺
Sir contest ke solution bhi upload krna start krdo ager possible ho yo boht help hogi🙏🙏🙏
Always waiting for your explanation videos
itne achhe tarike se koi kaise samjha sakta hai
💌💌
savior of stucked questions
nice, as per your suggestions earlier, we didn't need the solve functions, and I tried it worked with the given func itself only
Very well explained..!
Thanks a lot bhaiya ❤❤
After seeing this problem I definitely knew that it would be a recursive solution. However, I could not visualize the recursion for this problem which made it super tough for me.
But thanks to MIK, now it's become super easy to understand.
Crystal clear explanation man.
Best explanation sir
Great explaination mik!!!
thank you
Hello MIK
first of all I want to thank you for your amazing teaching skill, the way you taught its really amazing.❤❤❤❤❤❤❤❤
and could you please tell what software you are using to teach us , it will really help me to take notes ❤❤
I always wait for your explanation. pls try to release the video early.
Nice explaination
Bhot hi bhdiya bhai
Solved using i,j in solve
Thank you bhaiya
class Solution {
List solve(String s,int start,int end) {
List res = new ArrayList();
for(int i = start;i< end;i++) {
char ch = s.charAt(i);
if(ch == '-' || ch =='+' || ch =='*'){
List left = solve(s,start,i);
List right = solve(s,i+1,end);
for(int l : left) {
for(int r : right) {
if(ch == '+') {
res.add(l + r);
}
else if(ch == '-') {
res.add(l - r);
}
else{
res.add(l * r);
}
}
}
}
}
if(res.size() == 0) {
res.add(Integer.valueOf(s.substring(start,end)));
}
return res;
}
public List diffWaysToCompute(String expression) {
return solve(expression,0, expression.length());
}
}
bhaiya which mic you use for recording? Your voice is so clear.
Guruji 👌🏻
class Solution {
public List diffWaysToCompute(String exp) {
return solve(0,exp.length()-1,exp);
}
public List solve(int stIdx,int endIdx,String exp){
List list=new ArrayList();
for(int i=stIdx;i
when i was trying to come up with an idea
the ideas i had was of using a stack of sorts and I realised ki that wont be feasible
the other was about maybe storing it as expression trees and all, again was too complex lol
idk fi thats right even
same, i too was thinking of stack, sort.... 😕
love you bhai
class Solution {
public:
mapdp;
vectordiffWaysToCompute(string exp){
vectorans;
if(dp.find(exp)!=dp.end()){
return dp[exp];
}
for(int i=0;i
daku for reason!!!!
GOAT !!
Yeh question hard mai aayega not medium
inside first for loop in every time two inner for loop is running so time complexity will be o(n)*(2^n)*(n^2), is it right ?
I have one question. How the +, - and * is happening with string and getting added in integer vector
Notice that in the end when you only have digits (no operator), you will not enter for loop and in the end you will return the integer (stoi)
But let’s suppose in line 15 the x and y will be character right ? And they are getting stored in integer vector
I created separate array for numbers and operators
Very similar to Unique BST 2
class Solution {
public:
vector numbers;
vector op;
map mp;
vector solve(int l, int r){
if(l == r) {
return {numbers[l]};
}
if(mp.find({l , r}) != mp.end()){
return mp[{l , r}];
}
vector res;
for(int i=l;i
please do rotten oranges
Bhaiya I dont understand how result.push_back(x + y) is pushing an integer in the array as we didnt convert it to int cuz last case will only work if the whole string doesnt contain any operator plz help
bro don't be sad, I will make it crystal clear for you 🙂
Basically, for any expression, the base case will be an expression without any operator , cuz we keep Splitting the expression whenever we are seeing operator so obv. at the end, it will be an expression without any operator.
Since There will be No operator at the base, WE WILL NOT GO INTO THE LOOP and Return The Expression (no operand will be there) in the form INT (using stoi) to the Result Vector and It will be Returned to 'Left-Result' or 'Right - Result' Vector, Hence We Will Be Getting Vector of INT.
@@BatttttMan thx a lot bro ❤️
Thank you 😇❤️
as always nice explanation mik bhaiya
Sir vo har pairs ko check kar rahe uska bhi toh Time complexity hoga na and koi base case bhi nahi ha kyu?
Was using dp for this.. is it even necessary?
can this be done using mcm?
Pattern to ussi k jesa lag raha
Bhai biweekly 139 k contest k 3 and 4 p bna do
Hello bhaiya, jo left and right ka recursion call kar rhe hai usme 'string' se 'int' me kaise le rha hai.
wo call jab tak chalega ki for loop se koi element add nahi hua aur jo last me check karega reslut.isEmpty() tab wo string to int convert kar lega
Pehele question mein all possible ways keyword dekh Kar mere dimag mein backtracking aaya tha, fir koi approach nehi aaya dimag mein, to topics tag dekha woha dp tha par mujhe dp nehi aata, isiliye solve nehi hua, and options nehi samajh ayya question mein to recursion se kyese hoga ye bhi nehi hua.
So solved after watching explanation and approach.
How to find options from a recursion based question? Pls say bhaiya
Bhaeeya sab soch ney key baad code nhi likh pata any tips plz 😢
Practice
need dp approach as well bro
class Solution {
public:
unordered_mapmp;
vector diffWaysToCompute(string expression) {
vectorans;
int n = expression.size();
for(int i=0;i
Hello sir, why u didnt used dp in this problem?
Definitely you can.
Memoize it.
@@codestorywithMIK ok sir, Thank you
Constraints in the Question were Light....
Bhaiya, Chummi lelo, Kya video banayi h. 10 video dekh li kasam se, but this explanation was best....
😅😅
bhaiya ko toh m bhi dungaa
bhaiya if possible plz dbms p video bnadoo
meri job lg jyegi
😂
😂
Control bhai control
Hello MIK bhai, I’m new to your channel and I saw great response from people watching you. I have always faced difficulties in Dsa like understanding the concept and problem related to it is not the tougher job but whenever I’ve tried solving on my own it just doesn’t happen to be. I’m requesting you to provide a sheet/combined playlist starting from basic concepts and their problems to slowly climbing the difficulty ladder to advance or med-hard problems. Please take this into consideration 🥺
Ist view as always ❤