• <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
            99久久精品国产麻豆| 久久精品9988| 无码人妻久久久一区二区三区| 久久99国产精品久久99小说| 久久夜色精品国产欧美乱| 色综合久久中文综合网| 亚洲欧美国产日韩综合久久| 亚洲av日韩精品久久久久久a| 日本久久久精品中文字幕| 狠狠色丁香久久婷婷综合蜜芽五月| 久久婷婷成人综合色综合| 国产精品美女久久久网AV| 久久人人爽人人爽人人AV东京热 | 久久国产精品免费一区| 综合久久国产九一剧情麻豆 | 97久久超碰成人精品网站| 国产AV影片久久久久久| 国产成人精品综合久久久久| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 亚洲v国产v天堂a无码久久| 久久久久亚洲AV片无码下载蜜桃| 久久亚洲AV无码西西人体| 久久不见久久见免费视频7| 伊人色综合九久久天天蜜桃| 久久精品这里只有精99品| 97热久久免费频精品99| 国内精品久久久人妻中文字幕| 合区精品久久久中文字幕一区| 9999国产精品欧美久久久久久| 久久久久国产精品熟女影院| 伊人久久大香线蕉av一区| 日韩AV毛片精品久久久| 久久免费观看视频| 国产午夜福利精品久久| 99久久国产综合精品网成人影院| 奇米影视7777久久精品| 伊人久久大香线蕉亚洲五月天| 久久精品一区二区三区AV| 99蜜桃臀久久久欧美精品网站| 欧美亚洲国产精品久久| 偷窥少妇久久久久久久久|