The way you broke down the problem is excellent well done! I just subscribed. But an interviewer expecting me to do this in 20 minutes must fire themselves.
Keep it coming. The detailed and clear explanation of Hard problems really what sets this channel apart from other similar channels. Keep up the good work !!
woa, i subbed instantly because of the first couple second after i see the graph and how clear you explained ! great work! keep it going , i learned alot from you, youre great teacher
Crystal clear explanation. I like how you explain, steady giving the viewers time to understand and guess the next steps too. Liked and subscribed! thanks!
Best n cleat explanation of such complex problem! Thanks so much. Such problems are real tough ones as you may miss some or other edge case and logic will fail.
The best explanation for this problem ever. DP approach for this project is too complicated. The greedy approach was very well explained! SUBSCRIBED FOR LIFE!! :D
Superb explanation as usual. On a separate topic, I think if an interviewer gives you this problem in a 40 minute interview, he just doesn't want you to get the job.
confused about this part as well. during first iteration we will check lineLength + words[1] + (1-0-1) .. does this mean theres 0 spaces between first and second word? Edit: I figured it out it is because lineLength + words[j].length() + (j - i - 1) < maxLength if we did lineLength + words[j].length() + (j - i)
after so many editorials i found the only explanation of middle justify that i understood, thank you! after seeing the MIT text justify DP problem video i realized that is not the same as this XD
@@AlgosWithMichael i just came back to say that...i took a coding assessment and a variant of this problem came up! i wasn't able to finish the problem but i was glad i watched this video haha
Just one question, I found it hard to understand while(j < n && (lineLength + words[j].length() + (j - i - 1) < maxWidth) why do we need to subtract 1? Because if j is at index 2, i is at index 0, we at least need ( j - i) which is 2 spaces not just 1 space right ?
Nice explanation! But according to your logic your code on line 9 is wrong. The number of spaces needed (if we are including the jth word) should be equal to i-j. The reason your code runs sucessfully for all the test cases is because you made another mistake on the same line. The sum of linelength + word[j].lenght + space(s)length should be smaller than or EQUAL to maxwidth not smaller then. This means that the sum of those 3 elements < maxwidth + 1. Hence since both sides of the eq are actually 1 less than what they should be your code worked. Funny how two wrongs made a right. Great video tho!
man, I get so scattered brained solving these leetcode problems... it takes me around 2 hours just to solve one, but its so frustrating because I can easily write a well-rounded Android app in a short amount of time, but when it comes to test-taking and being 'watched' and solving these riddles - i don't do so well :( it's so discouraging that this is what is keeping me from joining companies I've always wanted to work at. Recruiters want to see if you can solve this problem, not your own sample/app code.
In your visual explanation, you said that we would compare "what" and "must" as 4 + 4 + 1, but in the code implementation, we do lineLength + words[j].length + (j - i - 1) which is 4 + 4 + 0. What was your thought process behind subtracting 1?
We access each word twice( once to calculate the j index and another time to actually add the word to the line) shouldn't the complexity be O(n^2 * m) (n = words.length(), m = maxWidth)??
Calculating the j index and adding the word to the line are separate, so I think it is O((n + n) * m) = O(n * m). It has been awhile since I have looked at the code for this problem though haha. I appreciate you watching and commenting!
For Java8, there is no "repeat" method for String class, so I added "String.join("",Collections.nCopies(spacesRight," "))". Is that good this approach?. I tested it and seems it is working as repeat spaces chars to add in the justification
The way you broke down the problem is excellent well done! I just subscribed. But an interviewer expecting me to do this in 20 minutes must fire themselves.
Keep it coming. The detailed and clear explanation of Hard problems really what sets this channel apart from other similar channels. Keep up the good work !!
That's really nice of you, thanks for watching man!
Thanks a million for the effort! The detailed explanation of hard problems really set the difference between you and other channels.
I’m here watching your vids again. One of the GOATED channels on TH-cam I’m being serious. You’re doing the GOD’s job :D thank you thank youuuuu🥺🥺🥺
Haha nice, thanks!
Can't ask for a better explanation. Crisp and clear. Thanks a lot for making this video.
Glad it was helpful!
Simply amazing! Hats off for your effort in creating this video. Thank you 🙏
My pleasure 😊
I looked at so many other youtube videos but this one is very clearly explained and easy to understand. Thanks for the post!!
No problem!
Dude, this is a crazy problem. Thank you for putting extra time to find a way to explain by using an easy method.
No problem at all!
Hands Down!!! The Best Explanation of this Question on TH-cam
I have watched many TH-camrs for this problem but this is the best explanation I have seen so far. Thanks a lot.
Nicely explained! Have been searching for this question for days... Thank you!
Worth 30 mins. Thanks, for this clear explanation!
Best video explaining this problem i've ever seen on TH-cam. Thanks!
You have explained in a very simple and detailed way. Keep it up!!!
woa, i subbed instantly because of the first couple second after i see the graph and how clear you explained ! great work! keep it going , i learned alot from you, youre great teacher
Crystal clear explanation. I like how you explain, steady giving the viewers time to understand and guess the next steps too. Liked and subscribed! thanks!
You're very welcome!
I really liked the pace of the video and the clarity in explanation. thanks a lot!
This is by far the most detailed and well explained video I've ever come across! Thanks a tonne!
Glad it was helpful!
Best n cleat explanation of such complex problem! Thanks so much.
Such problems are real tough ones as you may miss some or other edge case and logic will fail.
Yea, this problem in particular has SO many edge cases haha. Thanks for watching!
Amazing!!! Keep posting more videos . . You made it look so easy
I'm glad to hear that, thanks for watching!
your detailed explanation forced me to comment....this was the best possible explanation.
Thank you!
The best explanation for this problem ever. DP approach for this project is too complicated. The greedy approach was very well explained! SUBSCRIBED FOR LIFE!! :D
Haha thank you! I appreciate it. I agree the DP solution is super complicated.
You just made a hard problem so easy!
Superb explanation as usual. On a separate topic, I think if an interviewer gives you this problem in a 40 minute interview, he just doesn't want you to get the job.
Haha I totally agree with that. I feel like you would just have to know this question ahead of time
Thanks for your detailed explanation. You deserve more followers and thumbs up!
Thanks 👍
Man you are in some another level in explanation!! keep posting buddy
Haha thank you!
Superb!!! Such a clear explanation. Thank you so much.
Thank you so much!
Thanks a lot for this awesome explanation. Little confused with the "while (j
confused about this part as well.
during first iteration we will check lineLength + words[1] + (1-0-1) .. does this mean theres 0 spaces between first and second word?
Edit: I figured it out
it is because lineLength + words[j].length() + (j - i - 1) < maxLength
if we did lineLength + words[j].length() + (j - i)
had the same question, to help my self understand this, I changed it to ......+ j-i
One of best and detailed solution on the internet :). Keep going. You definitely get more subscribers.
I hope so! Thank you for the support
Good detailed Explanation, Thanks man
after so many editorials i found the only explanation of middle justify that i understood, thank you!
after seeing the MIT text justify DP problem video i realized that is not the same as this XD
Haha yea the DP version is really hard!
This question was asked at a job interview for a company that offered 4 lpa, so you can understand the level of competition in India.
This is the best explanation for the problem..Highly recommended and kudos to ur efforts!!
Thank you for the support!
brilliant explanation !!
you earned a new subscriber
Awesome, thank you!
Damn! Your explanation is clear! Thanks bro!
I appreciate it :)
Thanks, best explanation on YT so far.
Thank you, I appreciate that!
I'm half way through the video and your explanation has already impressed me!! You got a new subscriber❤
Awesome! Thank you!
this was honestly such a great explanation. you literally teach better than my professors! subscribed :)
I appreciate that
@@AlgosWithMichael i just came back to say that...i took a coding assessment and a variant of this problem came up! i wasn't able to finish the problem but i was glad i watched this video haha
Thanks for the amazing explanation.
Thank you very much for making this process very enjoyable ! Can't thank you enough Michael!
Just one question, I found it hard to understand while(j < n && (lineLength + words[j].length() + (j - i - 1) < maxWidth) why do we need to subtract 1? Because if j is at index 2, i is at index 0, we at least need ( j - i) which is 2 spaces not just 1 space right ?
My pleasure!
j - i = the number of words we have, if we do minus one, that is the number of spaces needed
I've found it so much helpful . I want to express heartiest gratitude brother.
Of course, I am glad to help!
Nice explanation! But according to your logic your code on line 9 is wrong. The number of spaces needed (if we are including the jth word) should be equal to i-j. The reason your code runs sucessfully for all the test cases is because you made another mistake on the same line. The sum of linelength + word[j].lenght + space(s)length should be smaller than or EQUAL to maxwidth not smaller then. This means that the sum of those 3 elements < maxwidth + 1. Hence since both sides of the eq are actually 1 less than what they should be your code worked. Funny how two wrongs made a right. Great video tho!
I was thinking about the same thing. Thanks for the clarification!
amazing !!!! the best explanation for Text justification!! Subscribed
Awesome, thank you!
This is the best explanation for this question
Thank you!
Well explained! Appreciate the hard work bro.
Such a nice and clear explanation. To the point, Thanks for your effort.
is code working
Thanks . great explanation. Love from India.
Thanks for watching!
Great explanation, I just got asked this by coursera rip
Great explanation!
Thanks!
elite explanation
King status, this problem is very hard, great job!
Yea, this problem really is a pain in the ass to learn lol
Wow. Great explanation.
Glad it was helpful!
Thank you for this! You definitely made it easier to understand
Super detailed and easy to understand! Thanks a ton, subscribed.
Awesome, thank you!
Really hard problem. Awesome explanation.
Glad it helped! This problem is insanely hard for sure
Thanks bro! The code is very neat. As well as explanation 👍
crystal clear explaination. Thank you.
Subscribed, thanks for creating this video, super helpful and crystal clear!
Anytime James
very clear and concise, loved it!
Glad it helped!
very nice Man
please continue in solving dynamic questions..
Most definitely!
Can I have your email to chat with you
you can find my email if you go to the about section I think
Great Explanation. Completely flawless. This should be getting more views. Subscribing. :) Thanks. Keep it up.
Much appreciated!
Very well explained ! Thanks
man, I get so scattered brained solving these leetcode problems... it takes me around 2 hours just to solve one, but its so frustrating because I can easily write a well-rounded Android app in a short amount of time, but when it comes to test-taking and being 'watched' and solving these riddles - i don't do so well :(
it's so discouraging that this is what is keeping me from joining companies I've always wanted to work at. Recruiters want to see if you can solve this problem, not your own sample/app code.
you won me over.
Haha glad you liked it!
Simply amazing. Thanks a lot mate!
Glad you liked it!
Amazing explanation!
Outstanding!
Glad you like it!
Useful 30 minutes.Thanks. Subscribed.
Awesome, thanks for the sub!
This is the best explanation. SUB++;
Thank you!
Thanks! Very clear explanation!
Glad it was helpful!
Thank you!
In your visual explanation, you said that we would compare "what" and "must" as 4 + 4 + 1, but in the code implementation, we do lineLength + words[j].length + (j - i - 1) which is 4 + 4 + 0. What was your thought process behind subtracting 1?
Awesome!!!
amazing video :)
Nice explanation!
Glad it was helpful!
best explanation !
Thanks
Subscribed, very helpful, thanks!
Awesome, thanks for subscribing and watching!
Great job!
Thanks!
The dry run though
superb video!
Thanks a lot!
Thank you very much!
No worries!
Way too good keep it up.
Thank you!
Thank u so much man
No problem!
Should've used monospace fonts to illustrate.
Where does that " ".repeat() comes from ? in which java version repeat exists for a string ?
I think Java 8, but you might need to fact check me
Thanks a lot
No problem!
Quality tutorial
Thank you!
We access each word twice( once to calculate the j index and another time to actually add the word to the line) shouldn't the complexity be O(n^2 * m) (n = words.length(), m = maxWidth)??
Calculating the j index and adding the word to the line are separate, so I think it is O((n + n) * m) = O(n * m). It has been awhile since I have looked at the code for this problem though haha. I appreciate you watching and commenting!
good video! very clear! But can you write the dynamic programming recurrence formula?
I find that solution pretty difficult, I haven't invested the time to solve it using DP
Flawless.
Thank you!
good work but now my head is spinning nine hundred thousand miles per hour...i am discombobulated 😂😂
lol yea this problem is confusing af
For Java8, there is no "repeat" method for String class, so I added "String.join("",Collections.nCopies(spacesRight," "))". Is that good this approach?. I tested it and seems it is working as repeat spaces chars to add in the justification
Yep, I see no reason as to why that would not work.
was lit
Medium to hard is good choice
I agree
THis video is awsome
Thank you! Glad you like it :)
I often get this "aaaaawwwwwww" (@28:49) moment
Hahah I know the feeling!
Do you have this code hosted on GIT?
Ok now use this greedy approach inside bottom up and that's the dp solution...
Haha the dp solution is pretty hard
Hey nice solution can you please provide your code !