• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Uriel's Corner

            Research Associate @ Harvard University / Research Interests: Computer Vision, Biomedical Image Analysis, Machine Learning
            posts - 0, comments - 50, trackbacks - 0, articles - 594
            模擬word的兩端對(duì)齊排版(最后一行不用對(duì)齊),模擬題


             1 #68
             2 #Runtime: 14 ms (Beats 75.43%)
             3 #Memory: 13.3 MB (Beats 67.24%)
             4 
             5 class Solution(object):
             6     def fullJustify(self, words, maxWidth):
             7         """
             8         :type words: List[str]
             9         :type maxWidth: int
            10         :rtype: List[str]
            11         """
            12         p = 0
            13         ans = []
            14         n_sp = []
            15         while p < len(words):
            16             tp = [words[p]]
            17             l = len(words[p])
            18             p += 1
            19             while p < len(words) and l + len(words[p]) + 1 <= maxWidth:
            20                 l += len(words[p]) + 1
            21                 tp.append(words[p])
            22                 p += 1
            23             n_sp = maxWidth - l
            24             tp_ans = ""
            25             if len(tp) == 1:
            26                 tp_ans += tp[0] + " " * n_sp
            27             else:
            28                 if p == len(words):
            29                     for i in range(len(tp) - 1):
            30                         tp_ans += tp[i] + " "
            31                     tp_ans += tp[-1]
            32                     for _ in range(n_sp):
            33                         tp_ans += " "
            34                 else:
            35                     for i in range(len(tp) - 1):
            36                         tp_ans += tp[i] + " " * (1 + n_sp // (len(tp) - 1))
            37                         if (n_sp % (len(tp) - 1)) > i:
            38                             tp_ans += " "
            39                     tp_ans += tp[-1]
            40             ans.append(tp_ans)
            41         return ans
            精品伊人久久大线蕉色首页| 国产精品视频久久| 久久精品二区| 久久久久久国产精品无码下载| 国产精品女同一区二区久久| 亚洲国产成人精品久久久国产成人一区二区三区综 | 国产福利电影一区二区三区,免费久久久久久久精 | 亚洲综合精品香蕉久久网97| 国产精品久久免费| 亚洲伊人久久成综合人影院| 午夜精品久久久久久久久| 亚洲国产精品久久久久婷婷软件| 久久久精品日本一区二区三区| 久久精品国产2020| 国产精品免费久久久久影院| 狠狠色丁香婷婷久久综合五月| 97精品久久天干天天天按摩| 久久精品亚洲男人的天堂| 久久久一本精品99久久精品88| 精品国产91久久久久久久a| 亚洲综合精品香蕉久久网| 九九热久久免费视频| 狠狠色丁香久久婷婷综合五月| 色青青草原桃花久久综合| 精品久久久久久久久久中文字幕 | 精品少妇人妻av无码久久| 人人狠狠综合久久亚洲| 久久最新精品国产| 久久99精品久久久久久久不卡| 久久免费视频1| 精品视频久久久久| 国产精品成人99久久久久 | 人妻无码久久一区二区三区免费| 久久久久国产精品麻豆AR影院| 久久精品国产99国产精偷| 99久久精品国产麻豆| 久久国产高潮流白浆免费观看| 色婷婷综合久久久久中文一区二区| 亚洲国产天堂久久久久久| 欧美午夜A∨大片久久| 久久久WWW成人免费毛片|