Alpha-Code
Alpha-Code
  • 787
  • 116 424
LeetCode 725 - Split Linked List In Parts - Java
Solution, explanation, and complexity analysis for LeetCode 725 in Java
Problem Description:
leetcode.com/problems/split-linked-list-in-parts
Code:
github.com/AnatoliySokolov98/LeetCode/tree/main/0725
#leetcode #java #linkedlists
zhlédnutí: 39

Video

LeetCode 1367 - Linked List in Binary Tree - Java
zhlédnutí 87Před 2 hodinami
Solution, explanation, and complexity analysis for LeetCode 1367 in Java Problem Description: leetcode.com/problems/linked-list-in-binary-tree Code: github.com/AnatoliySokolov98/LeetCode/tree/main/1367 #leetcode #java #linkedlists #tree
LeetCode 3217 - Delete Nodes From Linked List Present in Array - Java
zhlédnutí 110Před 4 hodinami
Solution, explanation, and complexity analysis for LeetCode 3217 in Java Problem Description: leetcode.com/problems/delete-nodes-from-linked-list-present-in-array/ Code: github.com/AnatoliySokolov98/LeetCode/tree/main/3217 #leetcode #java #linkedlists #set #array #delete
LeetCode 2028 - Find Missing Observations - Java
zhlédnutí 172Před 7 hodinami
Solution, explanation, and complexity analysis for LeetCode 2028 in Java Problem Description: leetcode.com/problems/find-missing-observations Code: github.com/AnatoliySokolov98/LeetCode/tree/main/2028 #leetcode #java #maths #array
LeetCode 874 - Walking Robot Simulation - Java
zhlédnutí 370Před 9 hodinami
Solution, explanation, and complexity analysis for LeetCode 874 in Java Problem Description: leetcode.com/problems/walking-robot-simulation/ Code: github.com/AnatoliySokolov98/LeetCode/tree/main/0874
LeetCode 1945 - Sum of Digits of String After Convert - Java
zhlédnutí 142Před 12 hodinami
Solution, explanation, and complexity analysis for LeetCode 1945 in Java Problem Description: leetcode.com/problems/sum-of-digits-of-string-after-convert/ Code: github.com/AnatoliySokolov98/LeetCode/tree/main/1945 #leetcode #java #strings #digits
LeetCode 1894 - Find The Student That Will Replace The Chalk - Java
zhlédnutí 296Před 14 hodinami
Solution, explanation, and complexity analysis for LeetCode 1894 in Java Problem Description: leetcode.com/problems/find-the-student-that-will-replace-the-chalk Code: github.com/AnatoliySokolov98/LeetCode/tree/main/1894 #leetcode #java #simulation #array #student
LeetCode 2022 - Convert 1D Array into 2D Array - Java
zhlédnutí 85Před 16 hodinami
Solution, explanation, and complexity analysis for LeetCode 2022 in Java Problem Description: leetcode.com/problems/convert-1d-array-into-2d-array Code: github.com/AnatoliySokolov98/LeetCode/tree/main/2022 #leetcode #java #array #matrix
LeetCode 2699 - Modify Graph Edge Weights - Java
zhlédnutí 1,9KPřed 21 hodinou
Solution, explanation, and complexity analysis for LeetCode 2699 in Java Problem Description: leetcode.com/problems/modify-graph-edge-weights/ Code: github.com/AnatoliySokolov98/LeetCode/tree/main/2699 #leetcode #java #graph #dijkstra
LeetCode 947 - Most Stones Removed With Same Row or Column - Java
zhlédnutí 354Před dnem
Solution, explanation, and complexity analysis for LeetCode 947 in Java Problem Description: leetcode.com/problems/most-stones-removed-with-same-row-or-column Code: github.com/AnatoliySokolov98/LeetCode/tree/main/0947 #leetcode #java #disjointsets #group
LeetCode 1905 - Count Sub Islands - Java
zhlédnutí 162Před dnem
Solution, explanation and complexity analysis for LeetCode 1905 in Java Problem Description: leetcode.com/problems/count-sub-islands/ Code: github.com/AnatoliySokolov98/LeetCode/tree/main/1905 #leetcode #java #dfs #island
LeetCode 1514 - Path with Maximum Probability - Java
zhlédnutí 181Před dnem
Solution, explanation, and complexity analysis for LeetCode 1514 in Java Problem Description: leetcode.com/problems/path-with-maximum-probability Code: github.com/AnatoliySokolov98/LeetCode/tree/main/1514 #leetcode #java #graph #probability
LeetCode 590 - N-ary Tree Postorder Traversal - Java
zhlédnutí 86Před dnem
Solution, explanation, and complexity analysis for LeetCode 590 in Java Problem Description: leetcode.com/problems/n-ary-tree-postorder-traversal Code: github.com/AnatoliySokolov98/LeetCode/tree/main/0590 #leetcode #java #tree #postorder #recursion #stack #iteration
LeetCode 145 - Binary Tree Postorder Traversal - Java
zhlédnutí 85Před 14 dny
Solution, explanation, and complexity analysis for LeetCode 145 in Java Problem Description: leetcode.com/problems/binary-tree-postorder-traversal Code: github.com/AnatoliySokolov98/LeetCode/tree/main/0145 #leetcode #java #binary #tree #traversal #stack #recursion
LeetCode 564 - Find the Closest Palindrome - Java
zhlédnutí 777Před 14 dny
Solution, explanation, and complexity analysis for LeetCode 564 in Java Problem Description: leetcode.com/problems/find-the-closest-palindrome/ Code: github.com/AnatoliySokolov98/LeetCode/tree/main/0564 #leetcode #java #palindrome
LeetCode 592 - Fraction Addition and Subtraction - Java
zhlédnutí 353Před 14 dny
LeetCode 592 - Fraction Addition and Subtraction - Java
LeetCode 476 - Number Complement - Java
zhlédnutí 105Před 14 dny
LeetCode 476 - Number Complement - Java
LeetCode 664 - Strange Printer - Java
zhlédnutí 649Před 14 dny
LeetCode 664 - Strange Printer - Java
LeetCode 1140 - Stone Game II - Java
zhlédnutí 499Před 14 dny
LeetCode 1140 - Stone Game II - Java
LeetCode 650 - 2 Keys Keyboard - Java
zhlédnutí 159Před 14 dny
LeetCode 650 - 2 Keys Keyboard - Java
LeetCode 264 - Ugly Number II - Java
zhlédnutí 118Před 21 dnem
LeetCode 264 - Ugly Number II - Java
LeetCode 1937 - Maximum Number of Points With Cost - Java
zhlédnutí 315Před 21 dnem
LeetCode 1937 - Maximum Number of Points With Cost - Java
LeetCode 624 - Maximum Distance in Arrays - Java
zhlédnutí 259Před 21 dnem
LeetCode 624 - Maximum Distance in Arrays - Java
LeetCode 860 - Lemonade Change - Java
zhlédnutí 50Před 21 dnem
LeetCode 860 - Lemonade Change - Java
LeetCode 719 - Find K-th Smallest Pair Distance - Java
zhlédnutí 211Před 21 dnem
LeetCode 719 - Find K-th Smallest Pair Distance - Java
LeetCode 40 - Combination Sum II - Java
zhlédnutí 120Před 21 dnem
LeetCode 40 - Combination Sum II - Java
LeetCode 703 - Kth Largest Element in a Stream - Java
zhlédnutí 129Před 21 dnem
LeetCode 703 - Kth Largest Element in a Stream - Java
LeetCode 1568 - Minimum Number of Days to Disconnect Island - Java
zhlédnutí 640Před 28 dny
LeetCode 1568 - Minimum Number of Days to Disconnect Island - Java
LeetCode 959 - Regions Cut By Slashes - Java
zhlédnutí 521Před 28 dny
LeetCode 959 - Regions Cut By Slashes - Java
LeetCode 840 - Magic Squares In Grid - Java
zhlédnutí 436Před 28 dny
LeetCode 840 - Magic Squares In Grid - Java

Komentáře

  • @BlackLightning73
    @BlackLightning73 Před 10 hodinami

    I had an interesting problem where I accidentally derived this algorithm. The question was to place each number of an input array into one of 2 arrays as you go, depending on which of the 2 arrays had more elements strictly greater than the current number at the time. I tracked a sorted version of each array, comparing the bisect.bisect_right index relative to the size of the array to get the strictly greater than count and then using bisect.insort to insert into the appropriate sorted array. The funny thing is I did that recently and didn't see the application it had to this problem haha

  • @sahilshah4698
    @sahilshah4698 Před 2 dny

    Love your videos, please make videos daily

  • @definitelysandeep
    @definitelysandeep Před 3 dny

    Arriving at that intuition is key. I started with a subset based solution, got TLE, did early pruning and returns with memoisation if we already have a result. Still got TLE. I guess this is more like a math observation question

    • @Alpha-Code
      @Alpha-Code Před 3 dny

      Yeah, but its like basic math. I can see how going down a dp route would make sense but then you need to keep track of an index and a total which is probably n^2 so would fail.

  • @MM.Esmail
    @MM.Esmail Před 3 dny

    Nice video

  • @zweitekonto9654
    @zweitekonto9654 Před 3 dny

    Voice too low. Can't even hear on full volume

  • @definitelysandeep
    @definitelysandeep Před 4 dny

    I created a if-else hell for directions it works just as the simulation says, but I wonder how what can we do if the inputs were large ? Binary search or something ?

    • @Alpha-Code
      @Alpha-Code Před 4 dny

      Would definitely be interesting if that were the case, we would basically have to figure out if we can go from a to b with no obstacle in the path in log(n) or better time. Something I'm thinking of is like maybe have a prefix sum of obstacles in the grid or something row by row and column by column that we can probably bin search with. So if you check obstacles at b vs obstacles at a we should have the same sum if there are none in the path then you can bin search through that space to find first place where it differs maybe. This would work if the obstacle numbers aren't too big but we have a lot of commands and the commands aren't 1-10 but like 1-10^4 or something.

  • @vaibhavvashist238
    @vaibhavvashist238 Před 5 dny

    What's the proof of it if we replace one by one every -1 weight to positive weight and at some point its less than equal to target is our result?

    • @Alpha-Code
      @Alpha-Code Před 5 dny

      Proof can be thought of in a couple steps: a. If we replace every single -1 with a 1 and we don't achieve this, then it is impossible and we are done. b. provided a is possible, if we replace one edge at a time we will eventually get to a point where the weight of the shortest path <= target. c. when we achieve b, we know for sure the last edge we added was necessary in order to do so (since without it we were not able to) and every edge we have not yet added is not required anymore. d. if we increase the weight of the last edge we added to make the path == target, there can be no shorter path because this edge has to be included in the shortest path from c and every path with this edge will increase equally. e. we can then make every edge not used = infinity to make sure this remains the shortest path.

  • @alifrahman7099
    @alifrahman7099 Před 6 dny

    12:15 for this subproblem shouldn't the result of this be 3 (just write e's then replace with T and D)? If you remove the first e then split it into TE and DE woudln't that return 2 + 2 which is 4? please correct me if i am wrong

    • @Alpha-Code
      @Alpha-Code Před 6 dny

      Yeah ur right should be 3. Splitting the way I showed in the video will be 4 but optimal is 3. Best split is getting rid of the last character right away then you have TEDE which then can split into TED and empty string so we get 3.

  • @tanishgotti3659
    @tanishgotti3659 Před 8 dny

    Why are we turning on only one at a time?

    • @Alpha-Code
      @Alpha-Code Před 8 dny

      @@tanishgotti3659 to know exactly which nodes turned on produce a valid shortest path.

  • @sirojiddinSoftwareEngineer

    Great job

  • @definitelysandeep
    @definitelysandeep Před 9 dny

    What if do something like this : We convert all -1 nodes into 1 and we try to save the shortes path. When we get the shortes path, we will travers it backwards and check if any of the edges is -1. We can add the difference between the shortest path and target to the first edge that was originally -1 For the rest we can update them with the MAX

    • @Alpha-Code
      @Alpha-Code Před 9 dny

      I did something similar in my Python solution. you can do that also. Save all paths during the Djikstra and sort by number of -1's then the path length. Then make one of the -1's in the path the difference and MAX the rest. Since n is only 100 its fine to save entire paths in the heap as you are finding shortest path. Don't need to go backwards just make every -1 into a 1 and add them all to graph and store (#of negative ones, dist, nodes in path) in the heap and use a min heap.

    • @tanishgotti3659
      @tanishgotti3659 Před 8 dny

      You can't pick the first edge that was originally -1 every time and expect it to satisfy. Picking different edges in the backwards traversal might give a different shortest path because other nodes in that path will be 1 now. See this test case: "edges = [[0,1,-1],[2,0,2],[3,2,6],[2,1,10],[3,0,-1]] source=1 destination =3 target =12" "[[0,1,1],[2,0,2],[3,2,6],[2,1,10],[3,0,11]]" is wrong "[[0,1,11],[2,0,2],[3,2,6],[2,1,10],[3,0,1]]" is correct.

    • @hittarthgoyal6689
      @hittarthgoyal6689 Před 8 dny

      @@tanishgotti3659 I did same mistake in my code

    • @tanishgotti3659
      @tanishgotti3659 Před 8 dny

      @@hittarthgoyal6689 this was a tricky corner case.

    • @Alpha-Code
      @Alpha-Code Před 8 dny

      @@tanishgotti3659 that's why you set the last -1 value you turned on to be target - shortest path to make sure it is the same once you get one smaller than target i.imgur.com/lyzG1U3.png and every node outside the path to MAX. Seems fine to me either way, your values were just wrong I think. In your first set of edges you just set the -1's incorrectly.

  • @sBlack007x
    @sBlack007x Před 9 dny

    You can also use for loop and scanner class to solve it... If it is possible

  • @rohanthakur9159
    @rohanthakur9159 Před 10 dny

    Thanks, Good explanation

  • @Alpha-Code
    @Alpha-Code Před 10 dny

    Had some background noise towards the end, I'll fix that up in the future.

  • @berserk.4121
    @berserk.4121 Před 11 dny

    Thanks for the video, but You can use grid2 instead of creating new visited array

    • @Alpha-Code
      @Alpha-Code Před 10 dny

      @@berserk.4121 yup I mentioned that in the video and said I don’t want to modify inputs

  • @vineethm6930
    @vineethm6930 Před 11 dny

    Excellent explanation !! Hats off to your consistency.

  • @hinalpatel1650
    @hinalpatel1650 Před 12 dny

    Thanks for explaning why we need 3*3 grid, because once you figure that out its basically number of island problem.

  • @chrisgu7991
    @chrisgu7991 Před 13 dny

    Just my intuition from what you have explained so far correct me if I am wrong. So for printer(i, j) it returns the minimal number of operations needed to print characters from [i, j]. In the for loop you are splitting whenever we see a matching character with our start character in the remaining string form [i + 1, j]. In that case we know that we could possibly achieve a lower number of operations for printing the first part [i, k]. The reason why we pass in dp(i, k - 1) is because when we have matching characters we are assuming that at index i we are already printing a sequence of similar character from i until index k inclusive. (i.e. "aba", when 0 == 2, at that instance we assume that we printed 'aaa' already, we actually only really consider the cost of printing 'ab' -> when we print 'a' -> 'aaa' and then when we print 'b' we are actually replacing the middle 'a' -> 'aba'.

    • @Alpha-Code
      @Alpha-Code Před 13 dny

      @@chrisgu7991 yup sounds right to me

  • @juanmacias5922
    @juanmacias5922 Před 14 dny

    I think pre/in/post traversal just clicked in my mind haha I wasn't sure why I always used pre for dfs xD

    • @Alpha-Code
      @Alpha-Code Před 14 dny

      Can use pre sometimes just need to understand the traversal order that you need for a particular problem.

  • @zweitekonto9654
    @zweitekonto9654 Před 14 dny

    I think it would be a good add on to show why a greedy method won't work here. That being just match the first occurrence with the last occurrence of the character trying to cover as many same characters as possible. Apart from that, excellent explanation

  • @satviksrinivas8764
    @satviksrinivas8764 Před 14 dny

    AlphaCode!!!

  • @ShubhamSharma-sf8wk
    @ShubhamSharma-sf8wk Před 15 dny

    Very hard to come up with a solution if you have never seen this problem before

    • @Alpha-Code
      @Alpha-Code Před 15 dny

      yea, ive seen a few like this before but hard to come up with all the edge cases. I think for some other ones I could build all palindromes and binary search through them or something.

  • @soubhagyamohapatra3665

    Quite a bit of edge cases in this problem, I was able to get to the reversing the first n/2 digits and subtracting and adding 1 to the significant bits but eventually gave up on trying to search for measures that would take care of these 101 and 99 cases. Glad I was able to come across your video! Great explanation, I wish you all the best in everything that you are doing. Thank you tons for posting content that helps people like us!

  • @CheeseFest-
    @CheeseFest- Před 15 dny

    Nice solution These types of problems can be so annoying

    • @Alpha-Code
      @Alpha-Code Před 15 dny

      Yeah this one was pretty annoying :)

  • @victor-fo9zf
    @victor-fo9zf Před 16 dny

    Thanks! This solution is by far the clearest one I have seen on CZcams. But is there any way to build the intuition for those kind of problems? Actually by observation, I can see that for most questions that requires counting subarray, sliding window is basically the way to go. My intuition was sliding window too when I attempted this problem, but I have no idea how did you come up with the 3 pointer approach. Any insights on this?

    • @Alpha-Code
      @Alpha-Code Před 15 dny

      You have to know what 3 pointer is useful for as opposed to 2 pointer. You can do all sliding window problems with 3 pointers, just usually the third one is redundant and doesn't give any extra information. So once you get how the third one helps, you can start asking yourself do I need it when you do the problems or do 2 give me all the info I need.

    • @victor-fo9zf
      @victor-fo9zf Před 15 dny

      @@Alpha-Code Thanks! I will try to delve in into how the third pointer is redundant in most cases but useful in this one. I just have one more question though and this is sth that I have been stuck when dealing with this problem - why is res += (min(lastMin, lastMax) - start + 1)? I don’t quite understand how come sth like (r-l+1) could be the number of subarray to add. How come in this formula we can find the number of subarray that fulfill the condition of the fixed bound? Sorry if this seems a little bit confusing, but I am quite lost about how this formula actually applies. Is there a mathematical way to think about this? And possibly how to apply this in other questions (e.g the scenario)?

    • @Alpha-Code
      @Alpha-Code Před 15 dny

      @@victor-fo9zf (min(lastMin, lastMax) - l + 1) is used cause you have to include lastMin and lastMax in all valid arrays so you take the min as this is the smallest array that includes both. Then anything that starts from there to start is a valid subarray if they end with r. And r - l + 1 is cause the number of arrays between 2 indices is r - l + 1.

    • @victor-fo9zf
      @victor-fo9zf Před 15 dny

      @@Alpha-Code I think an example may help with what I am trying to understand here: Suppose we have like nums = [1,5,5,1] and minK = 1 and maxK = 5. We initially know that boundary is at index 0, and it is all good from the first three index. We have res = 2 and the respective subarray are [1,5], [1,5,5]. However, I get a little bit confused when we are iterating at the last index. Now, minK reached to index 3 and maxK is on index 2. We do the calculation (2-0)+1=3 and res += 3. I know this is valid because in my observation, the corresponding subarray are [5,1], [5,5,1], [1,5,5,1]. How come the math kind of “knows” that there are three subarray for this case?

    • @Alpha-Code
      @Alpha-Code Před 15 dny

      @@victor-fo9zf min of last min and max is 2 so that means that for all arrays that end at r, they have to include index 2. So any array from l onward that includes index 2 that goes to r is valid. So 0-r 1-r and 2-r is valid. Math works out cause we updated bounds of valid arrays and can calculate how many end at r in O(1)

  • @ShubhamSharma-sf8wk
    @ShubhamSharma-sf8wk Před 16 dny

    Great video as usual, just a small suggestion, Could you please explain the problem first in detail? I still don't understand the problem at all :(

    • @juanmacias5922
      @juanmacias5922 Před 16 dny

      You're supposed to combine (add or subtract) fractions. Ex: 1/3 + 1/3 = 2/3

    • @Alpha-Code
      @Alpha-Code Před 16 dny

      Yeah I can spend more time on that sure. Thought this one was pretty clear just add fractions and simplify answer. But I'll spend more time on problem descriptions in the future no worries.

  • @sahebraojadhav9727
    @sahebraojadhav9727 Před 16 dny

    Nice

  • @evgeniybarykin2167
    @evgeniybarykin2167 Před 16 dny

    That's a really great explanation! The only part I'm a bit confused about is why this algorithm correctly handles strings where there are groups of letters in the middle of the string that are the same as the first letter. For example, "abaac".

    • @Alpha-Code
      @Alpha-Code Před 16 dny

      for that one you look for all characters that match starting one so abaa matches which would go down to aba then that goes down to ab for 0 cost. I explained something similar in the updated video for this problem.

    • @evgeniybarykin2167
      @evgeniybarykin2167 Před 16 dny

      @@Alpha-Code You're absolutely right! Thank you. The reason I couldn't figure it out was that I was building the decision tree incorrectly. If anyone else has the same question I did, try building a decision tree using a simple example.

  • @krugerbrent4270
    @krugerbrent4270 Před 17 dny

    I was quite close to this solution, just incrementing left pointer sequence was the miss. Thank you for this explanation.

  • @satviksrinivas8764
    @satviksrinivas8764 Před 17 dny

    thank you!

  • @MehmetDemir-xi3yy
    @MehmetDemir-xi3yy Před 17 dny

    Thanks for the video but actually you start at the end because you recurse to the end of the string with the line 27. I think It would be better if you explain from backwards.

    • @Alpha-Code
      @Alpha-Code Před 17 dny

      in line 27, it's recursing to the next character from the front. From i, j to i+1, j where i is front and j is end. Can do backwards or forwards should be the same so forwards just seems more intuitive if it doesn't matter.

    • @MehmetDemir-xi3yy
      @MehmetDemir-xi3yy Před 17 dny

      @@Alpha-Code I meant, the line 27 will be executed to the end of the string when i and j are same so you actually split the string from at the end of it. Am I wrong?

    • @Alpha-Code
      @Alpha-Code Před 17 dny

      @@MehmetDemir-xi3yy You can split from front or end but in this case it splits from front, you can log i and j and see for yourself though.

    • @MehmetDemir-xi3yy
      @MehmetDemir-xi3yy Před 17 dny

      @@Alpha-Code for input "abcabc" when you add this line below to line 30, "System.out.println(s.substring(i, k+1));" you will get output as cabc bcab abca so you are doing from backward to forward

    • @Alpha-Code
      @Alpha-Code Před 17 dny

      @@MehmetDemir-xi3yy Put that line at the top of the dp and just print i and j. Here's what I got for "abcabc" but either way result should be same imgur.com/IBOM5hR

  • @michaelroditis1952
    @michaelroditis1952 Před 17 dny

    398 days is crazy

  • @vishaalkumaranandan2894

    Please use dark mode next time It is just hurting my eyes

    • @Alpha-Code
      @Alpha-Code Před 17 dny

      @@vishaalkumaranandan2894 czcams.com/video/uAraW9iGmRQ/video.htmlsi=ML0XFaIiQeUmB7jf new one with dark mode

  • @nurliaidinjanarbyek8923

    If you wrote the whole code in the video with the explanation again, It would have been nice and easy to understand it👍👍

    • @Alpha-Code
      @Alpha-Code Před 17 dny

      Yeah I mostly write the code live. This one wasn't too long so probably could have done it. For the long ones, I prefer to write it ahead of time so the videos aren't like 30+ min.

  • @benjaminbarbosa3766
    @benjaminbarbosa3766 Před 18 dny

    Very nice explanation! Subscribed

  • @sohrabosmani5513
    @sohrabosmani5513 Před 18 dny

    I really like the way you explain this! You basically did a breakdown and then explained each part of your code that shows the breakdown steps and it all took about 15 min! Thanks man, I hope to see more of this! Edit: Also, not many resources do this in java!

  • @sahebraojadhav9727
    @sahebraojadhav9727 Před 18 dny

    I have doubt in our example when we will return hundred as the Alis score. At that time, we are taking minimum of our result and recursion call at that time. Bob will return minimum of hundred and his score. Can you explain how we are ensuring that Alice will get maximum I am a little bit confused. For bob min(result,100) in his case, we will end up with minimum score of bob

    • @Alpha-Code
      @Alpha-Code Před 18 dny

      The idea is in our function we are never calculating Bob's score. On Bob's turn we are simply returning the minimum for Alice given all the moves Bob can make. And on Alice's turn we are returning the maximum for Alice given all the moves that she can make. The function returns Alice's score given they both play optimally without calculating Bob's score at all, because the less points Alice gets the more Bob gets. So we can just focus on 1 score. So for example 2 you are referring to, the optimal play is Alice takes pile 1, Bob takes pile 2, Alice takes pile 3, Bob takes piles 4 and 5, and Alice takes pile 6. Alice's score is 1 + 3 + 100 from that = 104.

    • @sahebraojadhav9727
      @sahebraojadhav9727 Před 17 dny

      @@Alpha-Code thank bro got it

  • @sahebraojadhav9727
    @sahebraojadhav9727 Před 18 dny

    Bro I understand the solution of dp but fails to create my own solution what should I do to better in dp please reply

    • @Alpha-Code
      @Alpha-Code Před 18 dny

      You should do easier dp problems until you can create your own solutions then once you can do easier ones yourself consistently try slowly increasing difficulty. Start with some really basic ones where you have some basic choices to make like go down or right or something. Then go to mediums then go to hards.

  • @spinacker16
    @spinacker16 Před 18 dny

    Medium problem? why not easy?

  • @rahulbatra2596
    @rahulbatra2596 Před 18 dny

    Since both are playing optimally and there won't be any ties, and alice is starting the game, so he will always win. simply return true

  • @tuanhungphamcong1340
    @tuanhungphamcong1340 Před 18 dny

    wow, neetcode even got it wrong in this question but you have done a great job !!! thank

  • @vineethm6930
    @vineethm6930 Před 19 dny

    I was legit waiting for your video on this, thanks, as usual awesome explanation

  • @ahmadbasyouni9173
    @ahmadbasyouni9173 Před 19 dny

    only person to explain the question properly ty

  • @ThuyNhuTieu
    @ThuyNhuTieu Před 19 dny

    amazing solution! Btw what is the website used for simulation? Thanks

  • @geovannirodas9709
    @geovannirodas9709 Před 19 dny

    Goat

  • @Jenisha-tv2mi
    @Jenisha-tv2mi Před 19 dny

    nice explanation !

  • @ganeshjaggineni4097
    @ganeshjaggineni4097 Před 20 dny

    NICE SUPER EXCELLENT MOTIVATED

  • @_DashingAdi_
    @_DashingAdi_ Před 20 dny

    Hey can you post contest solutions aswell?

    • @Alpha-Code
      @Alpha-Code Před 20 dny

      Haven't done contests this week. If I do them later on during the week, I'll post them.

  • @Jenisha-tv2mi
    @Jenisha-tv2mi Před 21 dnem

    nice explanation!

  • @Jenisha-tv2mi
    @Jenisha-tv2mi Před 21 dnem

    nice solution!