Different Ways to Add Parentheses | Simple Story To Code | Leetcode 241 | codestorywithMIK

Поделиться
HTML-код
  • Опубликовано: 12 ноя 2024

Комментарии • 72

  • @psychologyfact2320
    @psychologyfact2320 Месяц назад +20

    Sir contest ke solution bhi upload krna start krdo ager possible ho yo boht help hogi🙏🙏🙏

  • @tanyasingh4023
    @tanyasingh4023 Месяц назад +12

    Always waiting for your explanation videos

  • @robot3.077
    @robot3.077 Месяц назад +2

    itne achhe tarike se koi kaise samjha sakta hai
    💌💌

  • @BombSquadHindiTipsTricks
    @BombSquadHindiTipsTricks Месяц назад +6

    savior of stucked questions

  • @aizad786iqbal
    @aizad786iqbal Месяц назад +1

    nice, as per your suggestions earlier, we didn't need the solve functions, and I tried it worked with the given func itself only

  • @priya_k98
    @priya_k98 Месяц назад +1

    Very well explained..!

  • @gauravbanerjee2898
    @gauravbanerjee2898 Месяц назад +1

    Thanks a lot bhaiya ❤❤

  • @akshaychavan5511
    @akshaychavan5511 Месяц назад +1

    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.

  • @aws_handles
    @aws_handles Месяц назад +1

    Crystal clear explanation man.

  • @AryanVats603
    @AryanVats603 Месяц назад +1

    Best explanation sir

  • @AshutoshAnand-o5l
    @AshutoshAnand-o5l Месяц назад +2

    Great explaination mik!!!

  • @abhinay.k
    @abhinay.k Месяц назад +3

    thank you

  • @priyobrotokarmakar6564
    @priyobrotokarmakar6564 Месяц назад +7

    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 ❤❤

  • @UmmeKNeha
    @UmmeKNeha Месяц назад

    I always wait for your explanation. pls try to release the video early.

  • @Playvish
    @Playvish Месяц назад +1

    Nice explaination

  • @piyushgupta5044
    @piyushgupta5044 Месяц назад +1

    Bhot hi bhdiya bhai

  • @focusman8801
    @focusman8801 Месяц назад +4

    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());
    }
    }

  • @anubhavsharma398
    @anubhavsharma398 Месяц назад +1

    bhaiya which mic you use for recording? Your voice is so clear.

  • @thekindspill
    @thekindspill Месяц назад

    Guruji 👌🏻

  • @KavyaGupta-cc5vp
    @KavyaGupta-cc5vp Месяц назад +1

    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

  • @sujayvikramgs8588
    @sujayvikramgs8588 Месяц назад

    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

    • @BatttttMan
      @BatttttMan Месяц назад

      same, i too was thinking of stack, sort.... 😕

  • @footballcreativeeverywhere260
    @footballcreativeeverywhere260 Месяц назад +2

    love you bhai

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 Месяц назад +1

    class Solution {
    public:
    mapdp;
    vectordiffWaysToCompute(string exp){
    vectorans;
    if(dp.find(exp)!=dp.end()){
    return dp[exp];
    }
    for(int i=0;i

  • @ago7506
    @ago7506 Месяц назад +2

    daku for reason!!!!

  • @Its_Shubham_Negi
    @Its_Shubham_Negi Месяц назад +2

    GOAT !!

  • @rohitaggarwal8776
    @rohitaggarwal8776 Месяц назад +1

    Yeh question hard mai aayega not medium

  • @SujalMahalaha
    @SujalMahalaha Месяц назад +1

    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 ?

  • @nileshsinha7869
    @nileshsinha7869 Месяц назад +1

    I have one question. How the +, - and * is happening with string and getting added in integer vector

    • @codestorywithMIK
      @codestorywithMIK  Месяц назад

      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)

    • @nileshsinha7869
      @nileshsinha7869 Месяц назад

      But let’s suppose in line 15 the x and y will be character right ? And they are getting stored in integer vector

  • @shobhitsingh8695
    @shobhitsingh8695 Месяц назад

    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

  • @rasish6749
    @rasish6749 Месяц назад

    please do rotten oranges

  • @vBlxzeYT
    @vBlxzeYT Месяц назад +3

    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

    • @BatttttMan
      @BatttttMan Месяц назад

      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.

    • @vBlxzeYT
      @vBlxzeYT Месяц назад

      @@BatttttMan thx a lot bro ❤️

    • @codestorywithMIK
      @codestorywithMIK  Месяц назад

      Thank you 😇❤️

  • @prathmeshkakde3731
    @prathmeshkakde3731 Месяц назад +1

    as always nice explanation mik bhaiya

  • @jeehub041
    @jeehub041 Месяц назад

    Sir vo har pairs ko check kar rahe uska bhi toh Time complexity hoga na and koi base case bhi nahi ha kyu?

  • @rev_krakken70
    @rev_krakken70 Месяц назад

    Was using dp for this.. is it even necessary?

  • @harshupadhyay2422
    @harshupadhyay2422 Месяц назад +1

    can this be done using mcm?

  • @anshror2583
    @anshror2583 Месяц назад +1

    Bhai biweekly 139 k contest k 3 and 4 p bna do

  • @omkarawasthi402
    @omkarawasthi402 Месяц назад

    Hello bhaiya, jo left and right ka recursion call kar rhe hai usme 'string' se 'int' me kaise le rha hai.

    • @prathmeshkakde3731
      @prathmeshkakde3731 Месяц назад

      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

  • @RishabhChatterjee-fg2gz
    @RishabhChatterjee-fg2gz Месяц назад

    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

  • @cosmicthor7330
    @cosmicthor7330 Месяц назад

    Bhaeeya sab soch ney key baad code nhi likh pata any tips plz 😢

  • @anammofazzaldurjoy7970
    @anammofazzaldurjoy7970 Месяц назад

    need dp approach as well bro

    • @yashnatholia2332
      @yashnatholia2332 Месяц назад +2

      class Solution {
      public:
      unordered_mapmp;
      vector diffWaysToCompute(string expression) {
      vectorans;
      int n = expression.size();
      for(int i=0;i

  • @the_only_one9415
    @the_only_one9415 Месяц назад +2

    Hello sir, why u didnt used dp in this problem?

  • @madhurgupta9575
    @madhurgupta9575 Месяц назад +19

    Bhaiya, Chummi lelo, Kya video banayi h. 10 video dekh li kasam se, but this explanation was best....

  • @saarvikjaiswal3458
    @saarvikjaiswal3458 Месяц назад

    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 🥺

  • @jeehub041
    @jeehub041 Месяц назад +3

    Ist view as always ❤