House Robber

Sdílet
Vložit
  • čas přidán 26. 03. 2019
  • For business inquiries email partnerships@k2.codes My Desk Setup
    Desk - bit.ly/3jfY195
    Chair - amzn.to/2O9TM3r
    Monitor - amzn.to/3rcSHGa
    Webcam - amzn.to/2NUmwgi
    Desktop - amzn.to/3tiySPL
    Laptops - amzn.to/3aRoN3Z
    iPad - amzn.to/2LlJzzJ
    Keyboard - amzn.to/3jfbxdd
    Mouse - amzn.to/36ElWtT
    Wrist Rest - amzn.to/3trrHF4 (pls don't buy this)
    Mouse Pad - amzn.to/2Myz2lt
    Microphone - amzn.to/3atNyTA
    Lamp - amzn.to/3jjfZYp
    Headphones - amzn.to/3tvr0KU (new model)
    Headphone Hook - amzn.to/3tr8uTC
    Blue Light Glasses - amzn.to/3cDVUdK
    Wireless Charger - amzn.to/39LY1uu
    Keyboard cable - amzn.to/2O5p2R5
    Mic arm - amzn.to/3cECZj8
    Audio interface - amzn.to/36HdWIi
    Cloudlifter - amzn.to/36VO6kf
    Laptop dock - amzn.to/2O2DsBw
    Motherboard - amzn.to/3rkiWuA
    Solid state - amzn.to/3rk5vuo
    CPU cooler - amzn.to/3tnwwPA
    CableMod - amzn.to/3tqbtM8
    CPU - amzn.to/3auG1ns
    Power supply - amzn.to/3trsAxo
    RAM - amzn.to/39JZcuf
    Designing Data-Intensive Applications - amzn.to/2YK4ek1
    Clean Code - amzn.to/3txqfB5
    Meditations - amzn.to/3cDa4fi
    SOCIAL
    ----------------------------------------------------------------------------------------------------------------
    Support me on Patreon: / kevinnaughtonjr
    Follow me on Twitter: / kevinnaughtonjr
    Follow me on Instagram: / kevinnaughtonjr
    Follow me on GitHub: github.com/kdn251
    MUSIC
    ----------------------------------------------------------------------------------------------------------------
    Blushes by Dj Quads
    / blushes
    #coding #interviews #softwareengineering Discord: bit.ly/K2-discord
  • Věda a technologie

Komentáře • 188

  • @KevinNaughtonJr
    @KevinNaughtonJr  Před 5 lety +121

    HOW DOPE IS MY SKI MASK

    • @jlecampana
      @jlecampana Před 5 lety +1

      Love the Mask! and well, this one is a very nice and do-able DP problem. I was wondering if you could do #276 - Paint Fence? I couldn't do it for the life of me, and it's labelled as "Easy", so maybe I'm missing something and you can enlighten me. Thanks in Advance Kevin!

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 5 lety +1

      @@jlecampana Haha thanks and don't pay attention to the labels they're all subjective! I actually think I already have a video on that problem if you wanna check it out! And anytime, thank YOU for your support!!!

    • @jlecampana
      @jlecampana Před 5 lety

      @@KevinNaughtonJr Oh I see it, you have done a video for LeetCode #256 - Paint House, How could I have missed it! I will see if I can actually solve the problem before watching your video. But I do think you should definitely check out #276, I could be wrong but I think it's Harder than most DP regulars. Have a nice day!

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 5 lety +1

      @@jlecampana I'll check it out thanks for the suggestion!!!

    • @PrathamMantri
      @PrathamMantri Před 5 lety +1

      Thanks Kevin for the best explanation of DP problem. I could use this example as a start for solving DP problems.

  • @alperozdamar517
    @alperozdamar517 Před 4 lety +22

    I saw this question in real interview and be able to do it. Thank you Kevin. :)

  • @aydasu
    @aydasu Před 5 lety +48

    love the dp questions. i feel like i am starting to get it. thanks Kevin!

  • @bingo7137
    @bingo7137 Před 4 lety +10

    Purely Awesome! i'm kinda struggling with understanding the dynamic programming problems and this is the best explanation out here. Thank you once again for all your help.

  • @ahasunos5914
    @ahasunos5914 Před 2 lety +1

    Kevin, I've been following your tutorials since past couple of weeks. You don't need to doubt why do you have subscribers. Thank you for all the concepts.

  • @wheresthebeach0138
    @wheresthebeach0138 Před 4 lety +1

    Hey Kevin, thank you for this! IMO, it's your best video to date :) I think you took the perfect amount of time to explain the logic before diving into the code; really clicked for me. Thank you!

  • @OlsZn
    @OlsZn Před 3 lety +1

    I love how you have the perfect camera window to block the previous tries of this question ;)

  • @mkhanyisigamedze4807
    @mkhanyisigamedze4807 Před 4 lety +5

    This took me 2 hours and I'm reminded of how understanding key concepts is so efficient. Love your videos

  • @jaidevsingh1009
    @jaidevsingh1009 Před 2 lety

    The clearest video on this problem, thank you!

  • @hookedbeans
    @hookedbeans Před 2 lety

    This is brilliant. Thank you!

  • @mohithguptakorangi1766
    @mohithguptakorangi1766 Před 3 lety +1

    now, that's how you explain "SHIT" in a "BEAUTIFUL" way

  • @Slumpicus
    @Slumpicus Před 5 lety +1

    You're killing it, dude. Keep it up!

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 5 lety

      Thanks Grayson I really appreciate it and don't worry I'm not going anywhere! New video is uploading now so get ready to check it out. Thanks so much for your support!

  • @selinadu1579
    @selinadu1579 Před 5 lety +2

    Awesome solution. Plz plz keep doing these tutorials. Love them!

  • @jaysaxena185
    @jaysaxena185 Před 3 lety +1

    Excellent Solution Kevin, cleared the concept of dp, through this explanation. Too Good, short, and on-point.

  • @priyanshmathur3010
    @priyanshmathur3010 Před rokem

    Bro, all those memes and explanations were lit!! Great Video :D

  • @mp0157
    @mp0157 Před 5 lety +2

    Thank you Kevin!! Good and simplified explanation! :) This helped!

  • @user-bc5wf2qq2r
    @user-bc5wf2qq2r Před 8 měsíci

    very intuitive, thanks!

  • @loirobin
    @loirobin Před 5 lety +1

    @Kevin your solution explanation is simple and crystal clear, thanks a lot

  • @ichdiegross
    @ichdiegross Před 4 lety +1

    You did a great job at explaining the concept properly!

  • @AliMehrpour-Volcano
    @AliMehrpour-Volcano Před 5 lety +1

    Crystal clear and neat explanation, good job as always 👍

  • @economicriskcapitalmodelpr9849

    This is my first visit to this channel and it's really impressive.Thanks for sharing your knowledge !! I am going to watch at least one video everyday.

  • @hyonsoo79
    @hyonsoo79 Před 4 lety

    Very easy to understand. Thank you!

  • @user-cl9el4iu4s
    @user-cl9el4iu4s Před 4 lety

    Thank you! Really explained my struggles.

  • @killersdeat0
    @killersdeat0 Před 5 lety +1

    Great intuition! A lot of people only keep 2 numbers (value if you robbed the house vs value if you didn't) and alternate saving the variables but I think that building the dp table is a lot more intuitive. We can also simplify the space complexity of the solution to be O(1) once we see the concept of building the table out in a real interview scenario

  • @mp0157
    @mp0157 Před 4 lety +1

    Very well explained intution! :) Thanks, this was of immense help!

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 4 lety +1

      Mihir Phatak thanks Mihir! Happy to hear the video was helpful :)

  • @svddwd
    @svddwd Před 3 lety

    Very nice explanation and approach . Thank you.

  • @wakita
    @wakita Před 5 lety +3

    Thanks for doing the dynamic programming problems, I've been trying various difficulty ones for a while, and one of the things thats helped me the most has been watching your Leetcode videos, along with BackToBack SWE and Tushar Roy.
    I did something pretty similar to you in my Javascript solution, but did it in place, modifying the original input array. I think this could also be done in constant space and not modifying the input by using a variable to represent max up to i - 1 and max up to i - 2.
    Javascript solution
    =====
    var rob = function(nums) {
    if (nums.length === 0) return 0;
    if (nums.length === 1) return nums[0];
    for (let i=1; i

  • @DhruvPatel-kg5ut
    @DhruvPatel-kg5ut Před 5 lety +2

    Awesome bro. This is the 3rd video I saw for this problem and now I actually could figure out the solution. Thanks.

  • @AmolGautam
    @AmolGautam Před 2 lety

    Thank you for the explaination.

  • @kairu86
    @kairu86 Před 3 lety

    Very helpful. Thanks!

  • @hitec1691
    @hitec1691 Před 5 lety +3

    Nicely explained. Thank you

  • @ishikanagar3236
    @ishikanagar3236 Před 2 lety

    loved it!

  • @studyaccount794
    @studyaccount794 Před 2 lety +2

    We can improve this solution even further. We can use 3 variables instead of using a complete new array. Just like we do in fibonacci. Code-
    public int rob(int[] nums) {
    int loot1 = 0;
    int loot2 = 0;
    for (int i = 0; i

  • @ENGCS_JaiSaxena
    @ENGCS_JaiSaxena Před rokem

    that is unbelivable , how are u able to solve so easily dude.great work.

  • @humblecoder9119
    @humblecoder9119 Před 5 lety +1

    Super explanation. Good to understand DP like this.

  • @vaishnavipamulapati9920

    i was struggling with this problem for a day 😔 but your explanation was very intuitive! thank you!

  • @tomiwaolasoko7291
    @tomiwaolasoko7291 Před 4 lety

    Thanks, great solution!

  • @peterdinklage3856
    @peterdinklage3856 Před 4 lety

    Awesome explanation mate!! thanks a lot!!

  • @georgiossamaras5063
    @georgiossamaras5063 Před 3 lety

    You don't need the if statement for the 2 houses case. Nice explanation, thanks!

  • @SaumyaSharma007
    @SaumyaSharma007 Před 3 lety +2

    Thank you so much Sir 🌟 Awesome explanation out there.
    Huge love and Respect from India 🌟🤗

  • @theanonymousfoodie8906
    @theanonymousfoodie8906 Před 2 lety +1

    this question was asked in my interview and I'm not able to solve that, now it looks very simple to me. Dammmmm!!!

  • @tirthjayswal9895
    @tirthjayswal9895 Před 3 lety

    Really Good Explentation

  • @ayanagrawal
    @ayanagrawal Před 3 lety +1

    Update : This is in medium now.

  • @ecea044gauravgogoi2
    @ecea044gauravgogoi2 Před 3 lety

    so nicely explained

  • @alammahtab08
    @alammahtab08 Před 4 lety +1

    Very well explained. Below is the code in case if someone wants to try out. Both, with the dp[] array and without dp array.
    With dp[] array : O(n) Space
    class Solution {
    public int rob(int[] nums) {
    if(nums == null || nums.length == 0)
    return 0;
    if(nums.length == 1)
    return nums[0];
    if(nums.length == 2)
    return Math.max(nums[0], nums[1]);

    int[] dp = new int[nums.length];
    dp[0] = nums[0]; dp[1] = Math.max(nums[0], nums[1]);
    for(int i = 2; i < nums.length; i++) {
    dp[i] = Math.max(nums[i] + dp[i-2], dp[i-1]);
    }
    return dp[nums.length-1];
    }
    }
    Without dp[] array : O(1) Space
    class Solution {
    public int rob(int[] nums) {
    if(nums == null || nums.length == 0)
    return 0;
    if(nums.length == 1)
    return nums[0];
    if(nums.length == 2)
    return Math.max(nums[0], nums[1]);

    int maxBeforeTwoHouse = nums[0];
    int maxBeforeOneHouse = Math.max(nums[0], nums[1]);
    int maxAtI = Math.max(nums[0], nums[1]);

    for(int i = 2; i < nums.length; i++) {
    maxAtI = Math.max(maxBeforeTwoHouse+ nums[i] , maxBeforeOneHouse);
    maxBeforeTwoHouse = maxBeforeOneHouse;
    maxBeforeOneHouse = maxAtI;
    }
    return maxAtI;
    }
    }
    github.com/eMahtab/house-robber

  • @lazycoder1910
    @lazycoder1910 Před 3 lety

    The explanation was really amazing

  • @anurag1908
    @anurag1908 Před 2 lety

    Just WOW!!!

  • @SoferPeOZN
    @SoferPeOZN Před 4 lety +35

    I think you got a dude moving in the background =)

  • @GURUYATHI
    @GURUYATHI Před 4 lety

    Great Solution..!

  • @yicai7
    @yicai7 Před 4 lety

    Omg I really like ur bgm at the beginning!!

  • @manulscode
    @manulscode Před 4 lety

    The robber is already sleeping in the background.:D

  • @sandeep_khangar
    @sandeep_khangar Před 2 lety

    Awesome explanation

  • @masoomraza5155
    @masoomraza5155 Před 2 lety

    Thank you
    you are a life saver

  • @ChocolateMilkCultLeader
    @ChocolateMilkCultLeader Před 4 lety +1

    Bro this one was genius. Hats off for a great solution

  • @vashi1989
    @vashi1989 Před 4 lety +1

    simple and nice explanation.. i dont think we need an extra array.. i tried with the provided nums arrays and it worked.

  • @ashmin3636
    @ashmin3636 Před 4 lety

    Good stuff, blud!

  • @marlegagaming1274
    @marlegagaming1274 Před 3 lety

    man, you made it look so easy...

  • @AshishSingh-dn8wb
    @AshishSingh-dn8wb Před 4 lety

    We actually don't need to check if nums.length==2 in the beginning. We are taking care of that in the loop itself. Anyway, loved the explanation. Love your videos man!

  • @crimsoncad3230
    @crimsoncad3230 Před 4 lety +2

    This is the 1st dp problem for which I paused the video and got the DP logic on my own.
    This should be the 1st video to watch when you start learning DP.
    Initially I thought of 2 independent loops that calculates the sum of all odd and even plce elements, then take the max out of it.
    But this seems more optimized and useful for new concept.

    • @vaichegodas
      @vaichegodas Před 4 lety

      you cant use 2 for loops to solve the problem

    • @shredchic
      @shredchic Před 3 lety

      I tried the odd/even thing as well first, but it will miss the max in some cases. Consider [8, 1, 9, 2, 5, 20] With checking odd vs. even, the max would be 23. However, the best robbery is 37. :)

  • @datajunkie3427
    @datajunkie3427 Před 3 lety +1

    The question starts with: You are a professional robber planning to rob houses along a street... That's a good start

  • @renetchi
    @renetchi Před 3 lety +1

    Why do you have subscribers? lollll because you're awesome!

  • @ankurgupta4696
    @ankurgupta4696 Před 4 lety

    Nice Explanation:)

  • @shubhoch2368
    @shubhoch2368 Před 2 lety

    Hey, first of all I really like your videos the way you approach a dp problem makes it so soo simple. Thank you! Can you please make a video on Leetcode problem number 152, I just want to know how you will approach that problem in case you have time to do so!

  • @MyVegeta
    @MyVegeta Před 4 lety

    yes i have the same reaction when i understand DB

  • @cocoarecords
    @cocoarecords Před 5 lety +1

    thanks wow well explained and ery clear

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 5 lety

      Thanks so much happy to hear the explanation made sense :)

  • @ridhwaans
    @ridhwaans Před 3 lety

    the confusing part is how the dp array carries over the largest sum without overlapping sums and maintaining non adjacency

  • @naveensmart87
    @naveensmart87 Před 4 lety

    awsome buddy !!!

  • @shubhammishra1225
    @shubhammishra1225 Před 2 lety

    Now this question become Leetcode medium. Still Dope mask and video.

  • @jagrutijamba9093
    @jagrutijamba9093 Před 3 lety +1

    Hi Kevin, nice try. But your alogrithm would not return the correct answer in the following case : [2,1,3,4]. The answer should be 2+4 = 6. As both the locations are non-consecutive and lead to max loot. Hence, I tried solving this problem with recursion instead.

  • @Manu-wb2uv
    @Manu-wb2uv Před 4 lety

    Makes sense. Thanks. Subscribed :D

  • @bhargavlokinindi1895
    @bhargavlokinindi1895 Před 5 lety +2

    You are awesome man, Neat & clear, keep it up bro

  • @arpitverma8060
    @arpitverma8060 Před 4 lety

    Awesome explanation of this question by a bottom up approach ..Can you explain it by a Top down ?

  • @wenzhongtan1358
    @wenzhongtan1358 Před 3 lety

    Great explanation! Just a question, we could probably shorten the last line to from dp[nums.length - 1] to dp[-1], right?

  • @ayeshaadhikari6123
    @ayeshaadhikari6123 Před 2 lety

    Thanks a tonne Kevin!

  • @ronaldabellano5643
    @ronaldabellano5643 Před 5 lety +1

    I like the music youre using!

  • @mayankdixit401
    @mayankdixit401 Před 4 lety

    My greatest achievement was that I was able to find that it is a dp problem. Now I can relate to the solution, thanks :)

  • @mostlyharmless161
    @mostlyharmless161 Před 3 lety

    Epic thumbnail btw xD

  • @heeseung5
    @heeseung5 Před 5 lety +4

    Nice mask haha made me laugh

  • @tavleenkaur6941
    @tavleenkaur6941 Před 4 lety

    Hey Kevin, your videos are very insightful and helping alot of people like me prepping up for the interviews.
    One thing I’d like to point in this question is that Is DP even necessary here? The first intuition that hit my mind when I read the question was to take the sum of the entire array (sum) and sum of all the alternate elements beginning from 0 (i.e. element at index 0 ,2, 4, till n-1 or n-2), lets call it X. The answer should be max(X , sum-X).
    Please let me know if there is something wrong in this approach ?

    • @darkcaper703
      @darkcaper703 Před 4 lety +1

      [2,1,1,2] -> u need to rob 1st and last to get maximum

  • @PrashantNigam
    @PrashantNigam Před 5 lety

    An improvement over this solution. Same as for Nth Fibonacci number. Without DP array.
    // T/S: O(n)/O(1)
    public int rob(int[] nums) {
    if (nums.length == 0)
    return 0;
    if (nums.length == 1)
    return nums[0];
    int twoBack = nums[0];
    int oneBack = Math.max(nums[0], nums[1]);
    int curr = b;
    for (int i = 2; i < nums.length; i++) {
    curr = Math.max(nums[i] + twoBack, oneBack);
    twoBack = oneBack;
    oneBack = curr;
    }
    return curr;
    }

  • @FrankLi92
    @FrankLi92 Před 5 lety

    Do we need to create a new array? Can we overwrite the current array for O(1) space?

  • @AhmadHassan-de9xo
    @AhmadHassan-de9xo Před 4 lety

    What if my sack where i put the money has a certain weight, and with each house's money there is a weight bounty i have to take into consideration, how would the program change ?

  • @lewisnt_
    @lewisnt_ Před 2 lety +1

    god tier thumbnail

  • @aashkas
    @aashkas Před 4 lety

    Wow finally a good explanation

  • @mohanmukherjee9061
    @mohanmukherjee9061 Před 5 lety +1

    Hey Kevin: Can you please add videos related to longest common substring, longest common palindromic strings -- using dynamic programming and explaining it in bit detail, I am having issues understanding it. Thanks

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 5 lety +1

      I'll see what I can do, thanks for the suggestion!

    • @rupalitiwari5012
      @rupalitiwari5012 Před 3 lety +1

      you can go through Aditya Verma Dynamic Programming videos. He has explained all those concepts very nicely.

  • @Vikasslytherine
    @Vikasslytherine Před 4 lety

    How to identify if a certain problem's going to need dynamic problem to solve?

  • @divyanshtyagi608
    @divyanshtyagi608 Před 4 lety

    Hey kevin , how would u go about to reduce the memory usage in this question ?

    • @a.yashwanth
      @a.yashwanth Před 4 lety +1

      No need to store all values in dp array cuz in the for loop we are accessing only untill previous 2 values.
      public int rob(int[] nums) {
      if(nums==null || nums.length==0){
      return 0;
      }
      if(nums.length==1){
      return nums[0];
      }
      if(nums.length==2){
      return Math.max(nums[0],nums[1]);
      }
      int l3=nums[0];
      int l2= Math.max(nums[0],nums[1]);
      int l1=0;
      for(int i=2;i

  • @rajdipdas9413
    @rajdipdas9413 Před 2 lety

    this problem can be solved by including first number from first index or excluding first number from first index and continue for the next indices.

  • @saulgoodman980
    @saulgoodman980 Před 3 lety +2

    My Python solution:
    def rob(nums):
    dp = [0, 0] # having 0s instead of nums[0] and max(nums[:2]) handles cases where len(nums) is 0 or 1 or 2
    for num in nums:
    dp.append(max(dp[-1], num + dp[-2]))
    return dp[-1]

    • @yv6358
      @yv6358 Před 3 lety

      Oh! Hey when did you start programming?

    • @saulgoodman980
      @saulgoodman980 Před 3 lety

      @@yv6358 It's been 5 years since I started (in school), but I've become serious only from the last 1.5 years

    • @yv6358
      @yv6358 Před 3 lety

      @@saulgoodman980 What happened to your career in law?

    • @saulgoodman980
      @saulgoodman980 Před 3 lety

      @@yv6358 Oh xD
      Well, you'll know in BCS S06 ;)

    • @yv6358
      @yv6358 Před 3 lety

      @@saulgoodman980 waiting for it

  • @ridhwaans
    @ridhwaans Před 3 lety

    this is a sliding window technique

  • @DanOhCaptainDaniel
    @DanOhCaptainDaniel Před 5 lety +2

    Every time you say "hopefully that's not too confusing" makes me start to assume the explanation you are about to make is going to be confusing haha. I really enjoy your videos, but I think the way you explain for some reason, it does not click for me. Maybe leetcode is still a little too complex for my programming level... I may just have to spend more time looking at the problems myself. Either way, thank you for having the solutions. I hope you answer every leetcode problem so we all have a reference solution for all the leetcode problems! Thank you again.

  • @Matt-xq6ow
    @Matt-xq6ow Před 2 lety

    I'm confused by the solution, can someone explain?
    I'm stuck understanding: dp[i] = Math.max(nums[i] + dp[i-2], dp[i-1]);
    Doesn't this mean we possibly have the chance of selecting an adjacent house instead of every other house?

  • @exaltedcelestial80
    @exaltedcelestial80 Před 3 lety

    Any referrence for dp? Where can I learn that? They don't teach it at school. lol

  • @seal0118
    @seal0118 Před 3 lety

    how do results not overlap, is there proof to this?

  • @user-gk3iq3lm7t
    @user-gk3iq3lm7t Před 2 lety

    I notice that you didn't use length + 1 for dp array this time, but for some other questions like number of coins and decoded ways all used length + 1 may I ask why this is otherwise?

  • @CoolnesXcore
    @CoolnesXcore Před 3 lety

    If you want to save some extra space, we can just add the elements to the nums array. :)

  • @atift5465
    @atift5465 Před 5 lety

    Ughh this is why I hate DP Problems. They always have a gotcha moment. It either clicks with us or it doesnt. I always had intuition that this was a DP problem before solving it but for some reason went towards the Brute Force and used many edge cases. Its hard to explain what I did and the problem worked for many cases but it failed many other cases. Anyhow, thanks for sharing again Kevin. Great work. Can you explain how you typically come up with solutions or algorithms to DP problems?

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 5 lety +1

      That's ok Atif it just takes practice keep working hard! What I normally try and do for dp problems is kinda what I did in this video...I try to think abou the simplest case. So whenever approaching a dp problem (and using bottom-up processing), I try to think about the absolute simplest case and build from there!

    • @atift5465
      @atift5465 Před 5 lety

      @@KevinNaughtonJr yea, true. I just need to tackle them more often until I can pick up exactly how to break down each problem into sub-problems. And as you said, it comes easier with practice. As always, thank you so much for this content and for replying.

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 5 lety

      @@atift5465 Definitely, it's all about practice and anytime Atif thanks for your continued support :)

  • @VillainTheatherCircus
    @VillainTheatherCircus Před 2 lety

    Kevin how many years of experienced have you had as a coder for using Java. Im intrested.

  • @HarinathSrinivas
    @HarinathSrinivas Před 4 lety

    Hey, the question you have solved is, "maximum sum in an array such that no 2 elements are adjacent". I was asked this question in an interview, tell me how to solve this.
    Given an array and an int value K, find Maximum sum of numbers, such that no 2 elements are adjacent and sum not greater than K.

  • @sunittechjourney9640
    @sunittechjourney9640 Před 3 lety

    What did you do on line 13? int[] dp = new int[nums.length] ? What is that?