Text Justification Algorithm (LeetCode)

  Рет қаралды 32,301

AlgosWithMichael

AlgosWithMichael

Күн бұрын

Пікірлер: 182
@antonyndungu5514
@antonyndungu5514 3 жыл бұрын
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.
@AshirwadPradhan007
@AshirwadPradhan007 4 жыл бұрын
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 !!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
That's really nice of you, thanks for watching man!
@sarthakgupta2005
@sarthakgupta2005 3 жыл бұрын
I have watched many KZbinrs for this problem but this is the best explanation I have seen so far. Thanks a lot.
@deanhu3410
@deanhu3410 2 жыл бұрын
Thanks a million for the effort! The detailed explanation of hard problems really set the difference between you and other channels.
@AshutoshPandey-se8vt
@AshutoshPandey-se8vt 2 жыл бұрын
Hands Down!!! The Best Explanation of this Question on KZbin
@sandeepkumarnagamalla1020
@sandeepkumarnagamalla1020 4 жыл бұрын
Can't ask for a better explanation. Crisp and clear. Thanks a lot for making this video.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Glad it was helpful!
@ranjithsubramaniam463
@ranjithsubramaniam463 2 жыл бұрын
Dude, this is a crazy problem. Thank you for putting extra time to find a way to explain by using an easy method.
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
No problem at all!
@sukanyachakraborty3359
@sukanyachakraborty3359 3 жыл бұрын
Simply amazing! Hats off for your effort in creating this video. Thank you 🙏
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
My pleasure 😊
@himanshusoni1512
@himanshusoni1512 3 жыл бұрын
Worth 30 mins. Thanks, for this clear explanation!
@PuspiPlaylist
@PuspiPlaylist 3 жыл бұрын
I looked at so many other youtube videos but this one is very clearly explained and easy to understand. Thanks for the post!!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
No problem!
@llz5160
@llz5160 2 жыл бұрын
Best video explaining this problem i've ever seen on KZbin. Thanks!
@harpercfc_
@harpercfc_ 2 жыл бұрын
I’m here watching your vids again. One of the GOATED channels on KZbin I’m being serious. You’re doing the GOD’s job :D thank you thank youuuuu🥺🥺🥺
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
Haha nice, thanks!
@rakshitsharma9989
@rakshitsharma9989 3 жыл бұрын
your detailed explanation forced me to comment....this was the best possible explanation.
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thank you!
@valentinmorales2633
@valentinmorales2633 3 жыл бұрын
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.
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Haha I totally agree with that. I feel like you would just have to know this question ahead of time
@TiffanyNg100
@TiffanyNg100 3 жыл бұрын
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
@ks-ow8mc
@ks-ow8mc 3 жыл бұрын
This is by far the most detailed and well explained video I've ever come across! Thanks a tonne!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Glad it was helpful!
@theghostwhowalk
@theghostwhowalk 4 жыл бұрын
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.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Yea, this problem in particular has SO many edge cases haha. Thanks for watching!
@sumeetchawla3545
@sumeetchawla3545 2 жыл бұрын
You have explained in a very simple and detailed way. Keep it up!!!
@rajd7002
@rajd7002 3 жыл бұрын
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!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
You're very welcome!
@amulya06holla
@amulya06holla 3 жыл бұрын
I really liked the pace of the video and the clarity in explanation. thanks a lot!
@PurvilBambharoliapurvil12c
@PurvilBambharoliapurvil12c 4 жыл бұрын
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
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Haha thank you! I appreciate it. I agree the DP solution is super complicated.
@mohamedbasid596
@mohamedbasid596 Жыл бұрын
Nicely explained! Have been searching for this question for days... Thank you!
@sumitanglekar6309
@sumitanglekar6309 4 жыл бұрын
Amazing!!! Keep posting more videos . . You made it look so easy
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
I'm glad to hear that, thanks for watching!
@gharatmayuresh15
@gharatmayuresh15 3 жыл бұрын
Thanks a lot for this awesome explanation. Little confused with the "while (j
@tommyypoon
@tommyypoon 3 жыл бұрын
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)
@kabichan1
@kabichan1 2 жыл бұрын
had the same question, to help my self understand this, I changed it to ......+ j-i
@Cube2deth
@Cube2deth 4 жыл бұрын
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
@AlgosWithMichael 4 жыл бұрын
Haha yea the DP version is really hard!
@prasaddeva675
@prasaddeva675 3 жыл бұрын
Man you are in some another level in explanation!! keep posting buddy
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Haha thank you!
@ujjvalsharma5055
@ujjvalsharma5055 3 жыл бұрын
One of best and detailed solution on the internet :). Keep going. You definitely get more subscribers.
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
I hope so! Thank you for the support
@hongliangfei3170
@hongliangfei3170 2 жыл бұрын
Thanks for your detailed explanation. You deserve more followers and thumbs up!
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
Thanks 👍
@abhishekravoor
@abhishekravoor 3 жыл бұрын
I'm half way through the video and your explanation has already impressed me!! You got a new subscriber❤
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Awesome! Thank you!
@suriyas1456
@suriyas1456 4 жыл бұрын
Thanks, best explanation on YT so far.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thank you, I appreciate that!
@shreyachaturvedi9782
@shreyachaturvedi9782 4 жыл бұрын
Superb!!! Such a clear explanation. Thank you so much.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thank you so much!
@pratapkumarchandra6488
@pratapkumarchandra6488 3 жыл бұрын
This is the best explanation for the problem..Highly recommended and kudos to ur efforts!!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thank you for the support!
@LifeIn_Japan
@LifeIn_Japan 4 жыл бұрын
amazing !!!! the best explanation for Text justification!! Subscribed
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Awesome, thank you!
@shoyebahmedrussel9471
@shoyebahmedrussel9471 3 жыл бұрын
I've found it so much helpful . I want to express heartiest gratitude brother.
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Of course, I am glad to help!
@yitingg7942
@yitingg7942 4 жыл бұрын
Thank you very much for making this process very enjoyable ! Can't thank you enough Michael!
@yitingg7942
@yitingg7942 4 жыл бұрын
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 ?
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
My pleasure!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
j - i = the number of words we have, if we do minus one, that is the number of spaces needed
@KateRipley
@KateRipley 3 жыл бұрын
this was honestly such a great explanation. you literally teach better than my professors! subscribed :)
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
I appreciate that
@KateRipley
@KateRipley 3 жыл бұрын
​@@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
@vaishali7250
@vaishali7250 4 ай бұрын
You just made a hard problem so easy!
@helloworl01
@helloworl01 Жыл бұрын
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.
@lostinparadification
@lostinparadification 4 жыл бұрын
This is the best explanation for this question
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thank you!
@truptijaiswal2623
@truptijaiswal2623 3 жыл бұрын
Such a nice and clear explanation. To the point, Thanks for your effort.
@adarshranjan5405
@adarshranjan5405 3 жыл бұрын
is code working
@deepakmishra1683
@deepakmishra1683 2 жыл бұрын
Well explained! Appreciate the hard work bro.
@sase1017
@sase1017 3 жыл бұрын
King status, this problem is very hard, great job!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Yea, this problem really is a pain in the ass to learn lol
@swathiayas
@swathiayas 3 жыл бұрын
Thank you for this! You definitely made it easier to understand
@suyashsharma7088
@suyashsharma7088 3 жыл бұрын
Super detailed and easy to understand! Thanks a ton, subscribed.
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Awesome, thank you!
@girish12359
@girish12359 Жыл бұрын
Good detailed Explanation, Thanks man
@psiddharth99
@psiddharth99 2 жыл бұрын
Thanks bro! The code is very neat. As well as explanation 👍
@shashankkumar6385
@shashankkumar6385 3 жыл бұрын
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!
@siavashjafarpour7645
@siavashjafarpour7645 2 жыл бұрын
I was thinking about the same thing. Thanks for the clarification!
@jameszhang3492
@jameszhang3492 3 жыл бұрын
Subscribed, thanks for creating this video, super helpful and crystal clear!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Anytime James
@deep.amrutiya
@deep.amrutiya 4 жыл бұрын
Great Explanation. Completely flawless. This should be getting more views. Subscribing. :) Thanks. Keep it up.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Much appreciated!
@raj_kundalia
@raj_kundalia 2 жыл бұрын
Thanks for the amazing explanation.
@anujpatel2916
@anujpatel2916 3 жыл бұрын
crystal clear explaination. Thank you.
@GenesisWithin
@GenesisWithin Жыл бұрын
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?
@ankitufl
@ankitufl 3 жыл бұрын
Really hard problem. Awesome explanation.
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Glad it helped! This problem is insanely hard for sure
@appstuff5778
@appstuff5778 Жыл бұрын
elite explanation
@rohankumarshah5679
@rohankumarshah5679 2 жыл бұрын
brilliant explanation !! you earned a new subscriber
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
Awesome, thank you!
@aneesaziz3611
@aneesaziz3611 3 жыл бұрын
Thanks . great explanation. Love from India.
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thanks for watching!
@yodaddy05
@yodaddy05 3 жыл бұрын
very clear and concise, loved it!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Glad it helped!
@maheriyajatinbharatbhai3538
@maheriyajatinbharatbhai3538 2 жыл бұрын
Very well explained ! Thanks
@kaikaidou
@kaikaidou 2 жыл бұрын
Damn! Your explanation is clear! Thanks bro!
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
I appreciate it :)
@MsSkip60
@MsSkip60 3 жыл бұрын
Simply amazing. Thanks a lot mate!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Glad you liked it!
@abuyahyadiab363
@abuyahyadiab363 4 жыл бұрын
very nice Man please continue in solving dynamic questions..
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Most definitely!
@abuyahyadiab363
@abuyahyadiab363 4 жыл бұрын
Can I have your email to chat with you
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
you can find my email if you go to the about section I think
@ranchisgoodonpizza6794
@ranchisgoodonpizza6794 3 жыл бұрын
Great explanation, I just got asked this by coursera rip
@Spham99
@Spham99 2 жыл бұрын
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.
@arjun.s5112
@arjun.s5112 4 жыл бұрын
Useful 30 minutes.Thanks. Subscribed.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Awesome, thanks for the sub!
@happyl4463
@happyl4463 3 жыл бұрын
Thanks! Very clear explanation!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Glad it was helpful!
@srijansingh361
@srijansingh361 3 жыл бұрын
Amazing explanation!
@saumya1singh
@saumya1singh 4 жыл бұрын
Outstanding!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Glad you like it!
@FernandoDiaz-jk2xg
@FernandoDiaz-jk2xg Жыл бұрын
Wow. Great explanation.
@AlgosWithMichael
@AlgosWithMichael Жыл бұрын
Glad it was helpful!
@rite2riddhi
@rite2riddhi 2 жыл бұрын
you won me over.
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
Haha glad you liked it!
@grantl3032
@grantl3032 4 жыл бұрын
Subscribed, very helpful, thanks!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Awesome, thanks for subscribing and watching!
@krutikakk4622
@krutikakk4622 3 жыл бұрын
Great explanation!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Glad it was helpful!
@dharamendraprajapati1301
@dharamendraprajapati1301 4 жыл бұрын
Nice explanation!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Glad it was helpful!
@sarveshchavan4391
@sarveshchavan4391 3 жыл бұрын
best explanation !
@zn4798
@zn4798 4 жыл бұрын
good video! very clear! But can you write the dynamic programming recurrence formula?
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
I find that solution pretty difficult, I haven't invested the time to solve it using DP
@vanitachalke3681
@vanitachalke3681 3 жыл бұрын
Where does that " ".repeat() comes from ? in which java version repeat exists for a string ?
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
I think Java 8, but you might need to fact check me
@nosoyyotampoco
@nosoyyotampoco 4 жыл бұрын
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
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Yep, I see no reason as to why that would not work.
@zerocool5673
@zerocool5673 4 жыл бұрын
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)??
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
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!
@priyankareddy7408
@priyankareddy7408 2 жыл бұрын
Thank you!
@amirabdou4940
@amirabdou4940 3 жыл бұрын
Great job!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thanks!
@tusharnain6652
@tusharnain6652 2 жыл бұрын
This is the best explanation. SUB++;
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
Thank you!
@subhamshaw1726
@subhamshaw1726 4 жыл бұрын
superb video!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thanks a lot!
@pradeepgjain
@pradeepgjain 3 жыл бұрын
Do you have this code hosted on GIT?
@tongwang535
@tongwang535 3 жыл бұрын
Thank you very much!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
No worries!
@chenamos6180
@chenamos6180 2 жыл бұрын
Awesome!!!
@himanshujain-bu1tv
@himanshujain-bu1tv Жыл бұрын
amazing video :)
@himanshushekhar5875
@himanshushekhar5875 3 жыл бұрын
Thanks
@nssg94
@nssg94 2 жыл бұрын
Should've used monospace fonts to illustrate.
@ameypalav2445
@ameypalav2445 4 жыл бұрын
Way too good keep it up.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thank you!
@code7434
@code7434 4 жыл бұрын
Thank u so much man
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
No problem!
@kose241
@kose241 4 жыл бұрын
Quality tutorial
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thank you!
@anusatyachoudhary7171
@anusatyachoudhary7171 4 жыл бұрын
Flawless.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thank you!
@shubhamsharma-sf6lx
@shubhamsharma-sf6lx 4 жыл бұрын
Thanks a lot
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
No problem!
@shubhamsharma-sf6lx
@shubhamsharma-sf6lx 4 жыл бұрын
Medium to hard is good choice
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
I agree
@023vinaytiwari6
@023vinaytiwari6 3 жыл бұрын
The dry run though
@rohitmishra1563
@rohitmishra1563 3 жыл бұрын
good work but now my head is spinning nine hundred thousand miles per hour...i am discombobulated 😂😂
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
lol yea this problem is confusing af
@apoorv7361
@apoorv7361 3 жыл бұрын
Hey nice solution can you please provide your code !
@iubob98
@iubob98 4 жыл бұрын
THis video is awsome
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thank you! Glad you like it :)
@023vinaytiwari6
@023vinaytiwari6 3 жыл бұрын
was lit
@ameypalav2445
@ameypalav2445 4 жыл бұрын
where can i kind the code!!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
I didn't post this anywhere, sorry! Maybe I should start posting the code on my Github
@ameypalav2445
@ameypalav2445 4 жыл бұрын
Yes :) it would be really helpful, great work though
@PoonamTomar12
@PoonamTomar12 3 жыл бұрын
@@AlgosWithMichael Please post your code, that will be great help
@aryansaxenafanclub3184
@aryansaxenafanclub3184 4 жыл бұрын
I often get this "aaaaawwwwwww" (@28:49) moment
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Hahah I know the feeling!
Text Justification - Leetcode 68 - Python
17:52
NeetCodeIO
Рет қаралды 29 М.
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 137 МЛН
Молодой боец приземлил легенду!
01:02
МИНУС БАЛЛ
Рет қаралды 2,1 МЛН
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
Amazon Coding Interview Question - First Missing Positive (LeetCode)
20:47
Lecture 20: Dynamic Programming II: Text Justification, Blackjack
52:12
MIT OpenCourseWare
Рет қаралды 542 М.
Google Coding Question - Making a Large Island (Hard)
25:11
AlgosWithMichael
Рет қаралды 16 М.
Word Ladder | Breadth First Search (LeetCode)
15:08
AlgosWithMichael
Рет қаралды 14 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Longest Increasing Path in a Matrix (DFS + Memoization)
18:47
AlgosWithMichael
Рет қаралды 19 М.
Google Coding Interview Question - Number of Closed Islands (LeetCode)
21:03
Worst leetcode hard problem - Text Justification : 68
13:06
Destination FAANG
Рет қаралды 2,8 М.
Text Justification Dynamic Programming
15:31
Tushar Roy - Coding Made Simple
Рет қаралды 143 М.
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 137 МЛН