• <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精品久久久久久| 久久精品国产色蜜蜜麻豆| 久久无码人妻精品一区二区三区| 国产成人精品久久免费动漫| 久久精品国产亚洲沈樵| 久久免费视频1| av国内精品久久久久影院| 精品人妻伦九区久久AAA片69| 午夜精品久久久久久| 久久国产精品无码HDAV| 久久精品亚洲福利| 亚洲AV日韩精品久久久久久| 久久99精品久久久久久齐齐 | 久久99精品九九九久久婷婷| 一本大道久久香蕉成人网| 久久国产热精品波多野结衣AV| 国产精品久久久久久久久久免费| 午夜人妻久久久久久久久| 国产香蕉97碰碰久久人人| 99久久国语露脸精品国产| 性做久久久久久久久久久| 66精品综合久久久久久久| 亚洲女久久久噜噜噜熟女| 亚洲国产日韩综合久久精品| 青青国产成人久久91网| 久久天天躁狠狠躁夜夜躁2O2O | 久久午夜福利无码1000合集| 青青草国产精品久久久久| 久久香蕉超碰97国产精品| 成人综合久久精品色婷婷| 久久精品国产72国产精福利| 四虎国产精品免费久久久| 久久99国产精品久久99| 色偷偷偷久久伊人大杳蕉| 精品无码久久久久国产动漫3d| 色综合久久久久综合99| 亚洲精品无码久久久久AV麻豆| 久久久久亚洲精品无码网址| 久久99精品国产99久久6| 久久久久无码精品|