135. Candy | Leetcode | Hard | Java | Greedy Algorithm | Striver's A to Z DSA Sheet/Course
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...
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
mam mera logic nahi lagg para questions mei......what to do!....mujeh aap jaise banna hai
Keep practicing
great explaination didi,, aur videoes banao
Thank youu !
great explanation
just one request : can you please take bigger examples during dry run?
so it would be more clear..
I will try my best