• <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
            久久亚洲国产最新网站| 久久久久久国产精品无码超碰| 久久亚洲国产午夜精品理论片| 欧美亚洲另类久久综合| 久久久久久无码国产精品中文字幕 | 青草国产精品久久久久久| 久久se精品一区二区| 四虎国产精品成人免费久久| 欧洲人妻丰满av无码久久不卡| 国产精品久久久99| 国产亚洲精久久久久久无码| 久久久久无码精品国产app| 久久精品国产99久久久| 久久综合色区| 久久99精品久久久久久野外| 伊人久久大香线蕉无码麻豆 | 色偷偷88欧美精品久久久| 久久精品国产91久久麻豆自制| 国产精品久久婷婷六月丁香| 久久综合狠狠综合久久97色| 久久精品国产一区二区三区日韩| 久久久久国产精品人妻| 久久成人国产精品一区二区| 美女写真久久影院| 97久久精品午夜一区二区| 亚洲AV日韩精品久久久久| 亚洲精品国产第一综合99久久| 久久亚洲AV无码西西人体| 久久99精品久久久久久秒播| 久久综合中文字幕| 99热热久久这里只有精品68| 久久这里只精品国产99热| 97久久超碰国产精品旧版| 97久久综合精品久久久综合| 国产精品18久久久久久vr | 99久久婷婷免费国产综合精品| 久久精品国产亚洲av日韩| 丰满少妇高潮惨叫久久久| 久久99国产精品久久| 99久久精品费精品国产| 久久精品亚洲男人的天堂|