<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      418. Sentence Screen Fitting

      Given a rows x cols screen and a sentence represented as a list of strings, return the number of times the given sentence can be fitted on the screen.

      The order of words in the sentence must remain unchanged, and a word cannot be split into two lines. A single space must separate two consecutive words in a line.

       

      Example 1:

      Input: sentence = ["hello","world"], rows = 2, cols = 8
      Output: 1
      Explanation:
      hello---
      world---
      The character '-' signifies an empty space on the screen.
      

      Example 2:

      Input: sentence = ["a", "bcd", "e"], rows = 3, cols = 6
      Output: 2
      Explanation:
      a-bcd- 
      e-a---
      bcd-e-
      The character '-' signifies an empty space on the screen.
      

      Example 3:

      Input: sentence = ["i","had","apple","pie"], rows = 4, cols = 5
      Output: 1
      Explanation:
      i-had
      apple
      pie-i
      had--
      The character '-' signifies an empty space on the screen.

       1 public class Solution {
       2     public int wordsTyping(String[] sentence, int rows, int cols) {
       3         String s = String.join("_", sentence) + "_";
       4         int len = s.length();
       5         int count = 0;
       6         int[] map = new int[len];
       7         for (int i = 1; i < len; ++i) {
       8             // if charAt(i) == '_', which means we saved an extra space
       9             map[i] = s.charAt(i) == '_' ? 1 : map[i-1] - 1;
      10         }
      11         for (int i = 0; i < rows; ++i) {
      12             count += cols;
      13             count += map[count % len];
      14         }
      15         return count / len;
      16     }
      17 }
       1     public int wordsTyping(String[] sentence, int rows, int cols) {
       2         String s = String.join(" ", sentence) + " ";
       3         int start = 0;
       4         int length = s.length();
       5         for (int i = 0; i < rows; i++) {
       6             start += cols;
       7             if (s.charAt(start % length) == ' ') {
       8                 start++;
       9             } else {
      10                 while (start >= 0 && s.charAt(start % length) != ' ') {
      11                     start--;
      12                 }
      13                 start++;
      14             }
      15         }
      16         
      17         return start / length;
      18     }

       

      posted @ 2021-07-05 01:28  北葉青藤  閱讀(58)  評論(0)    收藏  舉報
      主站蜘蛛池模板: AV极品无码专区亚洲AV| 国产成人av免费观看| 免费观看又色又爽又黄的崩锅| 免费看黄色亚洲一区久久| 内射中出无码护士在线| 国产系列丝袜熟女精品视频| 国产亚洲无线码一区二区| 日韩毛片在线视频x| 欧美成人精品一级在线观看| 久久ww精品w免费人成| 亚洲综合视频一区二区三区| 免费AV片在线观看网址| 久久99国产精品尤物| 日韩在线视频网| 亚洲中国精品精华液| 久久精品国产熟女亚洲av| 成人国产精品中文字幕| 久国产精品韩国三级视频| 行唐县| 亚洲av二区国产精品| 国产超碰无码最新上传| AV免费播放一区二区三区| 蜜桃无码一区二区三区| 日韩不卡在线观看视频不卡| 午夜激情福利在线免费看| 香河县| 鲁丝片一区二区三区免费| av天堂久久精品影音先锋| 无码国模国产在线观看免费| 产综合无码一区| 久久99精品久久久久麻豆| 高唐县| 亚洲一区二区中文字幕| 免费看欧美日韩一区二区三区| 在线免费不卡视频| 18av千部影片| 无码av免费毛片一区二区| 免费av深夜在线观看| 国产乱色国产精品免费视频| 国产精品先锋资源站先锋影院| 人妻熟女一二三区夜夜爱|