• <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的兩端對齊排版(最后一行不用對齊),模擬題


             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
            久久国产亚洲精品无码| 爱做久久久久久| 亚洲欧美一级久久精品| 久久精品桃花综合| 久久精品国产亚洲AV大全| 国内精品久久久久久久涩爱| 狠狠色丁香久久婷婷综合图片| 国产69精品久久久久APP下载| 久久精品国产网红主播| 欧美日韩中文字幕久久久不卡| 久久久久久久精品成人热色戒| 青青青青久久精品国产| 无码人妻精品一区二区三区久久| 日本福利片国产午夜久久| 亚洲精品白浆高清久久久久久| 国产精品美女久久久久av爽| 久久超碰97人人做人人爱| 亚洲欧洲精品成人久久奇米网| 精品久久久久久| 国产午夜免费高清久久影院| 国产精品久久久久a影院| 久久久亚洲精品蜜桃臀| 国产高潮久久免费观看| 99久久免费国产特黄| 亚洲人成伊人成综合网久久久| 久久精品国产黑森林| 成人免费网站久久久| 男女久久久国产一区二区三区| 亚洲精品高清一二区久久| 久久精品国产99久久香蕉| 色综合色天天久久婷婷基地| 狠狠色丁香婷婷综合久久来 | 久久精品视频网| 天天躁日日躁狠狠久久| 一本一道久久综合狠狠老| yy6080久久| 亚洲国产另类久久久精品黑人| 婷婷久久香蕉五月综合加勒比| 欧洲人妻丰满av无码久久不卡| 亚洲AV无码1区2区久久| 午夜精品久久久久久久|