Because of watching your videos on the daily problems for the past several weeks, I was able to solve today's hard problem on my own before your video even dropped. Thank so much for all your help, I'll still watch when you drop today because I will still learn something for sure. Keep up the great work!
u don't know how much this helped me, usually I can get the intuition down, but the coding part is still really hard for me, thanks for showing the code!
I'm sorry to hear that you failed your Google interview. I know how hard it can be to prepare for such a competitive and challenging process. But don't give up on your dream! You have the skills and the passion to succeed, and I'm sure you will get another chance to prove yourself.💪
@@HoppyGamer So the first variable is Ind Second is total time Third is total elements remain Since the observation is if we get the sum of time of the wall painted by the paid painter and if the remain wall is less or equal to the total time then free painter would paint all these remains wall in 1 sec each as stated in ques so we just want to minimize the cost of the paid painter
I tried for way too long to get a greedy approach working. Tried making different metrics like cost per time thinking that I'd want to keep the paid painter occupied for as long and cheap as possible while the free painter handles all the expensive
Same here.. I thought I had a greedy algorithm that worked for all these different test cases, but eventually realized I missed a test case where it didn't work. In retrospect I should've thought of other approaches first (even if they don't seem the most optimal), and think about a greedy approach last. If I am thinking of the greedy approach, I should try harder to disprove its correctness rather than prove it.
Can you make a series of dynamic programming videos where rather than explaining what dp is like other youtubers, you explain the intutions that a beginner might get when seeing such hard questions and try to code it, point out the mistakes and complexities, show how dp is originated or realized from exploring those ideas and then explain the dp solutions. I know a lot of work for you but it might help a lot of people like myself.
pls help to solve this : Given a string of the type "---F-FD-F" you need to group together all the F tiles ,You can do the following: swap F with - tile whcih will cost you x 2.Change a D to - whcih will cost you y. here F represents tile with FOOD on it and D is dirty tile and - is clean tile you can only swap F with - and not D directly(you can convert D to - then swap it with F so the cost will be for both swapping and changing D (x+y). write a code to find the minimum cost to group together all the F tile so that the cost is minimised. (python code plssss) in the above example "---F-FD-F" the min cost for x=0 and y=10 will be 10 . swap First F with the - next to it whcihc will result in "----FFD-F" and cost x=0 then convert D to - with cost y=10(total cost 0+10) which gives "----FF--F" . then swap the last F with - whcih will cost 0 and give the string ----FFF--?
my approach is : class Solution { public: int paintWalls(vector& cost, vector& time) { int n1 = cost.size(); for (int i = 0; i < n1; i++) { for (int j = i + 1; j < n1; j++) { if (cost[i] > cost[j]) { swap(cost[i], cost[j]); swap(time[i], time[j]); } } } int sum = 0 ; for(int i = 0 ; i
why i cant pass in test 2293 / 2557 ? cost = [42,8,28,35,21,13,21,35] time = [2,1,1,1,2,1,1,2] my output = 64 expected = 63 the only possible sum of values to result in 63 is 42+8+13, but thats like 2+1+1 time for the paid painter and 1+1+1+1+1 time for the free painter, the free painter cant work more than the paid one, right?, can someone help me? i think i miss something
Because of watching your videos on the daily problems for the past several weeks, I was able to solve today's hard problem on my own before your video even dropped. Thank so much for all your help, I'll still watch when you drop today because I will still learn something for sure. Keep up the great work!
u don't know how much this helped me, usually I can get the intuition down, but the coding part is still really hard for me, thanks for showing the code!
Thanks for these each day, it is helping me with my LeetCode routine greatly 🙏
Glad it's helpful :)
it's increasing my confidence
same here!
I failed my Google interview second time today... 😐... Will continue to leetcode.... Hopefully i will be prepared enough to clear it one day
Atleast your resume is getting shortlisted bro
@@lakshmanvengadesan9096 Ikr😂
I'm sorry to hear that you failed your Google interview. I know how hard it can be to prepare for such a competitive and challenging process. But don't give up on your dream! You have the skills and the passion to succeed, and I'm sure you will get another chance to prove yourself.💪
Tell us about kins of questions bro
i learn two new concepts regarding dp
1.tricky way to boil down three variable to two
2. introduce dp as a set
Can you explain how he made 3 variables into two? and why is sum(time) >= remaining walls
@@HoppyGamer
So the first variable is Ind
Second is total time
Third is total elements remain
Since the observation is if we get the sum of time of the wall painted by the paid painter and if the remain wall is less or equal to the total time then free painter would paint all these remains wall in 1 sec each as stated in ques so we just want to minimize the cost of the paid painter
I tried for way too long to get a greedy approach working. Tried making different metrics like cost per time thinking that I'd want to keep the paid painter occupied for as long and cheap as possible while the free painter handles all the expensive
Same here.. I thought I had a greedy algorithm that worked for all these different test cases, but eventually realized I missed a test case where it didn't work. In retrospect I should've thought of other approaches first (even if they don't seem the most optimal), and think about a greedy approach last. If I am thinking of the greedy approach, I should try harder to disprove its correctness rather than prove it.
@@vanchark But sometimes the greedy approach is the intended solution ¯\_(ツ)_/¯ There's literally a category on LC for greedy problems
Absolutely stunning piece of code Thank you for the clear explanation
Great explanation!!!
Your efforts are so valuable , thanks for your time
Can you make a series of dynamic programming videos where rather than explaining what dp is like other youtubers, you explain the intutions that a beginner might get when seeing such hard questions and try to code it, point out the mistakes and complexities, show how dp is originated or realized from exploring those ideas and then explain the dp solutions. I know a lot of work for you but it might help a lot of people like myself.
This pls
there's an indian youtuber who has a DP playlist, search "Striver DP playlist", there are around 56 videos explaining the pattern of each DP problem.
Great explanation as always . Thank you
watched understood done!
pls help to solve this :
Given a string of the type "---F-FD-F" you need to group together all the F tiles ,You can do the following:
swap F with - tile whcih will cost you x
2.Change a D to - whcih will cost you y.
here F represents tile with FOOD on it and D is dirty tile and - is clean tile
you can only swap F with - and not D directly(you can convert D to - then swap it with F so the cost will be for both swapping and changing D (x+y).
write a code to find the minimum cost to group together all the F tile so that the cost is minimised. (python code plssss)
in the above example "---F-FD-F"
the min cost for x=0 and y=10 will be 10 . swap First F with the - next to it whcihc will result in "----FFD-F" and cost x=0
then convert D to - with cost y=10(total cost 0+10) which gives "----FF--F" . then swap the last F with - whcih will cost 0 and give the string ----FFF--?
bro is this from the Trimble OA?
@@ayo_whatup3064 yeah , did you solve this one?
@@NishanPnab nah bro, only partial testcases passed🥲 I used greedy
my approach is :
class Solution {
public:
int paintWalls(vector& cost, vector& time) {
int n1 = cost.size();
for (int i = 0; i < n1; i++) {
for (int j = i + 1; j < n1; j++) {
if (cost[i] > cost[j]) {
swap(cost[i], cost[j]);
swap(time[i], time[j]);
}
}
}
int sum = 0 ;
for(int i = 0 ; i
Thanks bro
Honestly I was expecting some Priority Queue solution.
Even though i used the memorization, i got TLE
Whats up with the dp problems lately
yeah and theyre all hards lately
the @cache didn't speed it up
it throw memory limit exceeding:(
same here :(
take a shot every time he says 'pai'.
Bro woke up and chose vi-... Leetcode
leetcode destroying our weekends
why i cant pass in test 2293 / 2557 ?
cost = [42,8,28,35,21,13,21,35]
time = [2,1,1,1,2,1,1,2]
my output = 64
expected = 63
the only possible sum of values to result in 63 is 42+8+13, but thats like 2+1+1 time for the paid painter and 1+1+1+1+1 time for the free painter, the free painter cant work more than the paid one, right?, can someone help me? i think i miss something
Am I too dumb to not come up with this even with solving 300 problems?
Can anyone tell , whats wrong with my code ? -
class Solution:
def paintWalls(self, cost: List[int], time: List[int]) -> int:
dp = {}
def dfs(i, occupied):
if i == len(time):
return 0
if (i , occupied) in dp :
return dp[(i,occupied)]
if occupied != 0:
freePainterWork = dfs(i+1, occupied-1)
paidPainterWork = cost[i] + dfs(i+1 , occupied)
dp[(i,occupied)] = min(freePainterWork , paidPainterWork)
else:
paidPainterWork = cost[i] + dfs(i+1 , time[i])
dp[(i,occupied)] = paidPainterWork
return dp[(i,occupied)]
return dfs(0 , 0)
my comments are disappearing !!!