135. Candy | Leetcode | Hard | Java | Greedy Algorithm | Striver's A to Z DSA Sheet/Course

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • This is a hard level problem on leetcode and also a part of Striver's A to Z DSA Sheet/Course.
    We can arrive at a solution pretty intuitively if we carefully observe the details given in the question. As it involves the use of greedy approach, we should always try to find the best possible solution at every index we're visiting.
    Link to the problem: leetcode.com/problems/candy/
    Other problems for practice:
    • 45. Jump Game II | Lee...
    • 55. Jump Game | Leetco...
    • 678. Valid Parenthesis...
    • 860. Lemonade Change |...
    • 455. Assign Cookies | ...
    • 347. Top K Frequent El...
    • 621. Task Scheduler | ...
    • 846. Hand of Straights...
    • 992. Subarrays with K ...
    • 1423. Maximum Points Y...

Komentáře • 7

  • @user-sb6ns2hp4c
    @user-sb6ns2hp4c Před 3 měsíci +1

    reason you had to change line 11 conditions was due to line 10 loop condition you had to start iterating from the second last index but currently you are iterating from last index due to which line 11 condition was not running earlier

  • @studbanda9426
    @studbanda9426 Před 6 měsíci +3

    mam mera logic nahi lagg para questions mei......what to do!....mujeh aap jaise banna hai

  • @mayappapujari9259
    @mayappapujari9259 Před 5 měsíci +1

    great explaination didi,, aur videoes banao

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

    great explanation
    just one request : can you please take bigger examples during dry run?
    so it would be more clear..