EXPRESSION ADD OPERATORS | LEETCODE # 282 | PYTHON SOLUTION

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • In this video we are solving a tricky Facebook and Google interview question: Expression Add Operators (Leetcode # 282).
    This question is definitely pretty hard if you haven't seen it before but luckily the solution is quite intuitive and straightforward. You'll be able to understand it quite simply at the end of this video and it's actually quite easy to remember once you've seen it before.
    TIMESTAMPS:
    00:00 Intro
    00:21 Question Prompt
    00:43 Basic Example
    02:00 Solution Intuition
    07:42 Coding
    19:36 Time/Space Complexity
    22:30 Outro
  • Věda a technologie

Komentáře • 21

  • @vikramramkumar2087
    @vikramramkumar2087 Před 7 dny

    Damn.. what a solution!! I was thinking of generating all expressions using recursive backtracking (by inserting operators into num at alternate places), then using the eval() function in python, evaluate the string expression and see if eval(''.join(exp)) == target, append only those exp to res.
    Sadly, this approach was giving a TLE 🥲
    Great solution btw!

  • @45vinitthakkar56
    @45vinitthakkar56 Před 27 dny

    good explaination!

  • @aminebesbes6202
    @aminebesbes6202 Před rokem +2

    Great explanation! Thank you!
    Could you please prepare a general video to explain how to set-up a DFS parameters and its stop condition (Many LeetCode problems similar to this but always the toughest thing is to identify what parameters are needed for the DFS)

  • @aneeshakaushal267
    @aneeshakaushal267 Před měsícem

    Thanks. Very well explained :)

  • @YT.Nikolay
    @YT.Nikolay Před rokem +1

    Awesome! Thank you, we missed you!

  • @manojamrutharaj9071
    @manojamrutharaj9071 Před rokem

    Welcome back. Thanks for the cool explanation...

  • @drewlee7435
    @drewlee7435 Před 2 měsíci

    @Cracking FAANG Thanks for an AMAZING video. It's super concise and easy to understand.
    It's been an year but wanted to make a comment on this as I was thinking thru the complexities in the end.
    I am not too convinced that the Space Complexity is actually O(N), I think it should be at least O(3^N) similar to Time Complexity.
    I say this because I think the space needed doesn't grow linear with additional input, but rather exponentially to the additional input.
    Would love to know your thought on this. Thanks

  • @user-vt8dd6fj7v
    @user-vt8dd6fj7v Před rokem

    Nice video. I liked the video. Would like to request “Nested List Weight Sum II”. You solve the first version 4 month ago but not the 2nd one

  • @cindysu262
    @cindysu262 Před rokem

    Awesome!!

    • @crackfaang
      @crackfaang  Před rokem

      Glad you found it helpful! Subscribe if you haven’t already 😃

  • @lavanyam3224
    @lavanyam3224 Před 3 měsíci

    Thanks for the detailed explanation!! I've a query, are we using cur_res as a list instead of a string because strings are immutable and addition of a character to a string takes O(N)?

  • @rsKayiira
    @rsKayiira Před rokem

    Great video could you please do Valid Palindrome III LC 1216.

  • @sudhanshukumar3745
    @sudhanshukumar3745 Před rokem

    can you explain why in multiplication part of the dfs prev becomes curr_num*prev?

    • @lesterdelacruz5088
      @lesterdelacruz5088 Před 4 měsíci

      because when something like this happends `1-2*3*2` you need that must be the same as `1-(x*y)` at before the `-`. If you step through the code on `1-2*3*2` it will make sense. That's what i did.

    • @sudhanshukumar3745
      @sudhanshukumar3745 Před 4 měsíci

      @@lesterdelacruz5088 hey thanks for the explanation

  • @roywastaken
    @roywastaken Před 10 měsíci

    come back G, shit ain't the same without you

    • @crackfaang
      @crackfaang  Před 10 měsíci +1

      Comeback is planned… sometime later this month 👀

    • @roywastaken
      @roywastaken Před 10 měsíci

      @@crackfaang hell yea!!! prepping for Meta with your videos atm

    • @AP-eh6gr
      @AP-eh6gr Před 9 měsíci

      @@roywastaken same lol. Gotta do those 172 for last 6 mo

  • @sauravchandra10
    @sauravchandra10 Před 11 měsíci

    can anyone help me with the c++ code?

    • @anilrai9401
      @anilrai9401 Před 5 měsíci

      class Solution {
      public:
      vector ans;

      void rec(int cur_idx, string cur_res, long long cur_sum, long long prev, string &num, int target){
      if(cur_idx>=num.size()){
      if(cur_sum==target){
      ans.push_back(cur_res);
      }
      return;
      }

      string cur_str = "";

      for(int j=cur_idx;j