Text Justification Algorithm (LeetCode)

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ส.ค. 2024

ความคิดเห็น • 182

  • @antonyndungu5514
    @antonyndungu5514 2 ปีที่แล้ว +7

    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 ปีที่แล้ว +33

    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 ปีที่แล้ว +2

      That's really nice of you, thanks for watching man!

  • @deanhu3410
    @deanhu3410 2 ปีที่แล้ว +3

    Thanks a million for the effort! The detailed explanation of hard problems really set the difference between you and other channels.

  • @harpercfc_
    @harpercfc_ 2 ปีที่แล้ว

    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🥺🥺🥺

  • @sandeepkumarnagamalla1020
    @sandeepkumarnagamalla1020 3 ปีที่แล้ว +1

    Can't ask for a better explanation. Crisp and clear. Thanks a lot for making this video.

  • @sukanyachakraborty3359
    @sukanyachakraborty3359 3 ปีที่แล้ว +14

    Simply amazing! Hats off for your effort in creating this video. Thank you 🙏

  • @PuspiPlaylist
    @PuspiPlaylist 3 ปีที่แล้ว +1

    I looked at so many other youtube videos but this one is very clearly explained and easy to understand. Thanks for the post!!

  • @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.

  • @AshutoshPandey-se8vt
    @AshutoshPandey-se8vt 2 ปีที่แล้ว

    Hands Down!!! The Best Explanation of this Question on TH-cam

  • @sarthakgupta2005
    @sarthakgupta2005 3 ปีที่แล้ว

    I have watched many TH-camrs for this problem but this is the best explanation I have seen so far. Thanks a lot.

  • @mohamedbasid596
    @mohamedbasid596 ปีที่แล้ว

    Nicely explained! Have been searching for this question for days... Thank you!

  • @himanshusoni1512
    @himanshusoni1512 3 ปีที่แล้ว +2

    Worth 30 mins. Thanks, for this clear explanation!

  • @llz5160
    @llz5160 2 ปีที่แล้ว

    Best video explaining this problem i've ever seen on TH-cam. Thanks!

  • @sumeetchawla3545
    @sumeetchawla3545 2 ปีที่แล้ว +1

    You have explained in a very simple and detailed way. Keep it up!!!

  • @TiffanyNg100
    @TiffanyNg100 3 ปีที่แล้ว +4

    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

  • @rajd7002
    @rajd7002 3 ปีที่แล้ว +2

    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!

  • @amulya06holla
    @amulya06holla 2 ปีที่แล้ว +1

    I really liked the pace of the video and the clarity in explanation. thanks a lot!

  • @ks-ow8mc
    @ks-ow8mc 3 ปีที่แล้ว +1

    This is by far the most detailed and well explained video I've ever come across! Thanks a tonne!

  • @theghostwhowalk
    @theghostwhowalk 4 ปีที่แล้ว +2

    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 ปีที่แล้ว +5

      Yea, this problem in particular has SO many edge cases haha. Thanks for watching!

  • @sumitanglekar6309
    @sumitanglekar6309 4 ปีที่แล้ว +8

    Amazing!!! Keep posting more videos . . You made it look so easy

    • @AlgosWithMichael
      @AlgosWithMichael  4 ปีที่แล้ว +2

      I'm glad to hear that, thanks for watching!

  • @rakshitsharma9989
    @rakshitsharma9989 2 ปีที่แล้ว

    your detailed explanation forced me to comment....this was the best possible explanation.

  • @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.

  • @vaishali7250
    @vaishali7250 หลายเดือนก่อน

    You just made a hard problem so easy!

  • @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 ปีที่แล้ว +1

      Haha I totally agree with that. I feel like you would just have to know this question ahead of time

  • @hongliangfei3170
    @hongliangfei3170 2 ปีที่แล้ว

    Thanks for your detailed explanation. You deserve more followers and thumbs up!

  • @prasaddeva675
    @prasaddeva675 3 ปีที่แล้ว +1

    Man you are in some another level in explanation!! keep posting buddy

  • @shreyachaturvedi9782
    @shreyachaturvedi9782 4 ปีที่แล้ว +4

    Superb!!! Such a clear explanation. Thank you so much.

  • @gharatmayuresh15
    @gharatmayuresh15 3 ปีที่แล้ว +2

    Thanks a lot for this awesome explanation. Little confused with the "while (j

    • @tommyypoon
      @tommyypoon 3 ปีที่แล้ว +5

      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

  • @ujjvalsharma5055
    @ujjvalsharma5055 3 ปีที่แล้ว

    One of best and detailed solution on the internet :). Keep going. You definitely get more subscribers.

  • @girish12359
    @girish12359 ปีที่แล้ว

    Good detailed Explanation, Thanks man

  • @Cube2deth
    @Cube2deth 3 ปีที่แล้ว

    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

  • @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.

  • @pratapkumarchandra6488
    @pratapkumarchandra6488 3 ปีที่แล้ว

    This is the best explanation for the problem..Highly recommended and kudos to ur efforts!!

  • @rohankumarshah5679
    @rohankumarshah5679 2 ปีที่แล้ว

    brilliant explanation !!
    you earned a new subscriber

  • @kaichengjia5240
    @kaichengjia5240 2 ปีที่แล้ว

    Damn! Your explanation is clear! Thanks bro!

  • @suriyas1456
    @suriyas1456 4 ปีที่แล้ว +1

    Thanks, best explanation on YT so far.

  • @abhishekravoor
    @abhishekravoor 3 ปีที่แล้ว

    I'm half way through the video and your explanation has already impressed me!! You got a new subscriber❤

  • @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

  • @raj_kundalia
    @raj_kundalia 2 ปีที่แล้ว

    Thanks for the amazing explanation.

  • @yitingg7942
    @yitingg7942 3 ปีที่แล้ว +1

    Thank you very much for making this process very enjoyable ! Can't thank you enough Michael!

    • @yitingg7942
      @yitingg7942 3 ปีที่แล้ว

      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  3 ปีที่แล้ว

      My pleasure!

    • @AlgosWithMichael
      @AlgosWithMichael  3 ปีที่แล้ว

      j - i = the number of words we have, if we do minus one, that is the number of spaces needed

  • @shoyebahmedrussel9471
    @shoyebahmedrussel9471 3 ปีที่แล้ว

    I've found it so much helpful . I want to express heartiest gratitude brother.

  • @shashankkumar6385
    @shashankkumar6385 3 ปีที่แล้ว +5

    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!

  • @LifeIn_Japan
    @LifeIn_Japan 4 ปีที่แล้ว +3

    amazing !!!! the best explanation for Text justification!! Subscribed

  • @lostinparadification
    @lostinparadification 3 ปีที่แล้ว

    This is the best explanation for this question

  • @deepakmishra1683
    @deepakmishra1683 2 ปีที่แล้ว

    Well explained! Appreciate the hard work bro.

  • @truptijaiswal2623
    @truptijaiswal2623 3 ปีที่แล้ว

    Such a nice and clear explanation. To the point, Thanks for your effort.

  • @aneesaziz3611
    @aneesaziz3611 3 ปีที่แล้ว +1

    Thanks . great explanation. Love from India.

  • @ranchisgoodonpizza6794
    @ranchisgoodonpizza6794 2 ปีที่แล้ว

    Great explanation, I just got asked this by coursera rip

  • @webdecoded
    @webdecoded 2 ปีที่แล้ว

    Great explanation!

  • @appstuff5778
    @appstuff5778 ปีที่แล้ว

    elite explanation

  • @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

  • @FernandoDiaz-jk2xg
    @FernandoDiaz-jk2xg ปีที่แล้ว

    Wow. Great explanation.

  • @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.

  • @ankitufl
    @ankitufl 3 ปีที่แล้ว

    Really hard problem. Awesome explanation.

    • @AlgosWithMichael
      @AlgosWithMichael  3 ปีที่แล้ว

      Glad it helped! This problem is insanely hard for sure

  • @psiddharth99
    @psiddharth99 2 ปีที่แล้ว

    Thanks bro! The code is very neat. As well as explanation 👍

  • @anujpatel2916
    @anujpatel2916 3 ปีที่แล้ว

    crystal clear explaination. Thank you.

  • @jameszhang3492
    @jameszhang3492 3 ปีที่แล้ว

    Subscribed, thanks for creating this video, super helpful and crystal clear!

  • @yodaddy05
    @yodaddy05 3 ปีที่แล้ว

    very clear and concise, loved it!

  • @abuyahyadiab363
    @abuyahyadiab363 3 ปีที่แล้ว +1

    very nice Man
    please continue in solving dynamic questions..

    • @AlgosWithMichael
      @AlgosWithMichael  3 ปีที่แล้ว +1

      Most definitely!

    • @abuyahyadiab363
      @abuyahyadiab363 3 ปีที่แล้ว

      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

  • @deep.amrutiya
    @deep.amrutiya 4 ปีที่แล้ว

    Great Explanation. Completely flawless. This should be getting more views. Subscribing. :) Thanks. Keep it up.

  • @maheriyajatinbharatbhai3538
    @maheriyajatinbharatbhai3538 2 ปีที่แล้ว

    Very well explained ! Thanks

  • @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.

  • @rite2riddhi
    @rite2riddhi ปีที่แล้ว

    you won me over.

  • @MsSkip60
    @MsSkip60 3 ปีที่แล้ว

    Simply amazing. Thanks a lot mate!

  • @democrats9579
    @democrats9579 2 ปีที่แล้ว

    Amazing explanation!

  • @saumya1singh
    @saumya1singh 4 ปีที่แล้ว +1

    Outstanding!

  • @arjun.s5112
    @arjun.s5112 4 ปีที่แล้ว

    Useful 30 minutes.Thanks. Subscribed.

  • @tusharnain6652
    @tusharnain6652 2 ปีที่แล้ว +1

    This is the best explanation. SUB++;

  • @happyl4463
    @happyl4463 3 ปีที่แล้ว

    Thanks! Very clear explanation!

  • @priyankareddy7408
    @priyankareddy7408 2 ปีที่แล้ว

    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?

  • @chenamos6180
    @chenamos6180 2 ปีที่แล้ว

    Awesome!!!

  • @himanshujain-bu1tv
    @himanshujain-bu1tv ปีที่แล้ว

    amazing video :)

  • @dharamendraprajapati1301
    @dharamendraprajapati1301 3 ปีที่แล้ว

    Nice explanation!

  • @sarveshchavan4391
    @sarveshchavan4391 3 ปีที่แล้ว

    best explanation !

  • @himanshushekhar5875
    @himanshushekhar5875 3 ปีที่แล้ว

    Thanks

  • @grantl3032
    @grantl3032 4 ปีที่แล้ว

    Subscribed, very helpful, thanks!

    • @AlgosWithMichael
      @AlgosWithMichael  4 ปีที่แล้ว

      Awesome, thanks for subscribing and watching!

  • @amirabdou4940
    @amirabdou4940 3 ปีที่แล้ว

    Great job!

  • @023vinaytiwari6
    @023vinaytiwari6 3 ปีที่แล้ว

    The dry run though

  • @subhamshaw1726
    @subhamshaw1726 3 ปีที่แล้ว

    superb video!

  • @tongwang535
    @tongwang535 3 ปีที่แล้ว

    Thank you very much!

  • @ameypalav2445
    @ameypalav2445 3 ปีที่แล้ว

    Way too good keep it up.

  • @code7434
    @code7434 4 ปีที่แล้ว

    Thank u so much man

  • @nssg94
    @nssg94 2 ปีที่แล้ว

    Should've used monospace fonts to illustrate.

  • @vanitachalke3681
    @vanitachalke3681 2 ปีที่แล้ว

    Where does that " ".repeat() comes from ? in which java version repeat exists for a string ?

    • @AlgosWithMichael
      @AlgosWithMichael  2 ปีที่แล้ว +1

      I think Java 8, but you might need to fact check me

  • @shubhamsharma-sf6lx
    @shubhamsharma-sf6lx 4 ปีที่แล้ว

    Thanks a lot

  • @kose241
    @kose241 4 ปีที่แล้ว

    Quality tutorial

  • @zerocool5673
    @zerocool5673 3 ปีที่แล้ว

    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!

  • @zn4798
    @zn4798 3 ปีที่แล้ว

    good video! very clear! But can you write the dynamic programming recurrence formula?

    • @AlgosWithMichael
      @AlgosWithMichael  3 ปีที่แล้ว

      I find that solution pretty difficult, I haven't invested the time to solve it using DP

  • @anusatyachoudhary7171
    @anusatyachoudhary7171 4 ปีที่แล้ว

    Flawless.

  • @rohitmishra1563
    @rohitmishra1563 3 ปีที่แล้ว

    good work but now my head is spinning nine hundred thousand miles per hour...i am discombobulated 😂😂

  • @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.

  • @023vinaytiwari6
    @023vinaytiwari6 3 ปีที่แล้ว

    was lit

  • @shubhamsharma-sf6lx
    @shubhamsharma-sf6lx 4 ปีที่แล้ว

    Medium to hard is good choice

  • @iubob98
    @iubob98 4 ปีที่แล้ว

    THis video is awsome

  • @aryansaxenafanclub3184
    @aryansaxenafanclub3184 4 ปีที่แล้ว

    I often get this "aaaaawwwwwww" (@28:49) moment

  • @pradeepgjain
    @pradeepgjain 3 ปีที่แล้ว

    Do you have this code hosted on GIT?

  • @biswamohandwari6460
    @biswamohandwari6460 3 ปีที่แล้ว

    Ok now use this greedy approach inside bottom up and that's the dp solution...

  • @apoorv7361
    @apoorv7361 3 ปีที่แล้ว

    Hey nice solution can you please provide your code !