Text Justification - Leetcode 68 - Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ค. 2024
  • Solving Leetcode 68, Text Justification. While it's definitely difficult, I don't think it's as bad as you would expect. Though the problem is poorly worded imo.
    🚀 neetcode.io/ - A better way to prepare for Coding Interviews
    🥷 Discord: / discord
    🐦 Twitter: / neetcode1
    🐮 Support the channel: / neetcode
    ⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
    💡 DYNAMIC PROGRAMMING PLAYLIST: • House Robber - Leetco...
    Problem Link: leetcode.com/problems/text-ju...
    0:00 - Read the problem
    0:30 - Drawing Explanation
    6:45 - Coding Explanation
    leetcode 68
    #neetcode #leetcode #python

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

  • @Syed_Shifat
    @Syed_Shifat 10 หลายเดือนก่อน +13

    Hey Neet, I love you, man. I wish I could meet you someday. Your videos are greatly organized and so helpful.

  • @flueesyblueesy6246
    @flueesyblueesy6246 10 หลายเดือนก่อน +8

    This question has been the bane of me for years now

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

      😂😂😂😂its nice to know someone out there

  • @VidyaBhandary
    @VidyaBhandary 10 หลายเดือนก่อน +2

    Finally!!! Thank you. Needed this one.

  • @RagingAcid
    @RagingAcid 10 หลายเดือนก่อน +4

    I've been waiting for this one from you

  • @MP-ny3ep
    @MP-ny3ep 10 หลายเดือนก่อน +3

    Thank you so much for the daily problems

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

    Thanks for uploading the dailies again!

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

    Great Coding there, thank you!

  • @impatientgaming9868
    @impatientgaming9868 3 หลายเดือนก่อน +1

    Had to rewatch once but good explanation.

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

    Amazing explanation.

  • @shawnzhang528
    @shawnzhang528 10 หลายเดือนก่อน +1

    So elegant answer

  • @garth2356
    @garth2356 10 หลายเดือนก่อน +8

    They legit asked this exact same question in the coding round for DevRev and I was able to solve it!

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

      wish I saw this video before I got a problem in a coding round today. Couldn't figure out the justification part, but at least separated the words correctly

  • @uptwist2260
    @uptwist2260 10 หลายเดือนก่อน +1

    Thanks for the daily

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

    very useful video ,thanks for amazing explaination . Can you please tell me where is this mention that there has to be space between 2 consecutive words in the line. Like in example 3 : line#3 has the word enough which can be fir easily in the line#2 if we don't keep space in between two words.Please tell me if I have misinterpreted the question ,because I can not find any such restriction in question where it says that there has to be a space in between consecutive words.On the other hand , it clearly mentions that " each line has exactly maxWidth characters ", see question is only talking about characters , no constraints given about compulsary word prefix/suffix . Please help

  • @aadil4236
    @aadil4236 10 หลายเดือนก่อน +2

    The Problem was good. It imporves your thinking. Can you share more problem like these? Thanks for the explanation!

    • @NeetCodeIO
      @NeetCodeIO  10 หลายเดือนก่อน +4

      Yeah I really enjoyed it. I don't remember many like this tbh, but if anyone else does feel free to mention them here.

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

      When you say "It improves your thinking", does this specific problem benefit you in coming up with more efficient and elegant approaches, especially with to string related problems? Even though many LC problems can enhance your problem-solving skills, does this specific one opens up to newer techniques you could use based upon what you have said?

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

    I got this one in a CodeSignal assessment. Solving this PLUS 3 other (smaller) questions in a 70-minute time frame? Forget it.

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

      shitt.......😬😬

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

    Is the space complexity of this is o(n) where n is the number of words for each line....? please correct me if I'm wrong....

  • @ruthlessogre2441
    @ruthlessogre2441 10 หลายเดือนก่อน +5

    This was one of the easiest hard questions.

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

      yes but the edge cases are pretty confusing. therre isnt much logic to be applied in this.

  • @Benstokes555
    @Benstokes555 2 หลายเดือนก่อน +1

    saaari duniya see jeeth ke me aaya hu idhar🤓🤓

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

    I have a question at line #27. In case the line contains one word with exactly the same number of characters as maxWidth, won't the last line contain maxWidth + 1 characters? Why is it not giving an error for exceeding the maxWidth. I'm not familiar with Python so if you/someone can help me understand this.

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

      It won't because #27 is the delimiter is what is put between words in this case. If there is only one word, then no delimiters are added.

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

    I tried to find python solution of this problem from your website, but it is not there. Could you verify?

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

    How long did it take you to solve it?

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

      took me 1.5 hrs grinding it with a pen and paper

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

    you missed a case to handle the single word sentences which is not the last sentence: if len(line) == 1: line[0] += ' ' * extra_space this line would come in around line 13 of your code

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

    need mmmmmooorre