• <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

            [LeetCode]ZigZag Conversion-2014.01.08

            Posted on 2014-01-11 02:17 Uriel 閱讀(93) 評論(0)  編輯 收藏 引用 所屬分類: LeetCode
            水題,但理解題意略糾結,其實就是把| / | / | / |這樣排列的字符陣列轉化為按行來的,直接模擬就好~

             1 class Solution {
             2 public:
             3     string convert(string s, int nRows) {
             4         if(nRows == 1) return s;
             5         string res;
             6         int i = 0, j = 0, n = s.length();
             7         while(j < s.length()) {
             8             res.push_back(s[j]);
             9             j += 2 * nRows - 2;
            10         }
            11         for(i = 1; i < nRows - 1; ++i) {
            12             j = i;
            13             while(j < s.length()) {
            14                 res.push_back(s[j]);
            15                 j += 2 * nRows - 2 * (i + 1);
            16                 if(j < s.length()) {
            17                     res.push_back(s[j]);
            18                     j += 2 * i;
            19                 }
            20             }
            21         }
            22         j = nRows - 1;
            23         while(j < s.length()) {
            24             res.push_back(s[j]);
            25             j += 2 * nRows - 2;
            26         }
            27         return res;
            28     }
            29 };
            国产精品久久99| 久久无码AV中文出轨人妻| 国产精品久久久久久一区二区三区 | 亚洲精品高清久久| 国产伊人久久| 久久精品国产AV一区二区三区 | 99久久国产综合精品五月天喷水 | 国产成人综合久久久久久| 亚洲第一永久AV网站久久精品男人的天堂AV | 国产精品99久久99久久久| 婷婷久久精品国产| 国内精品久久久久| 久久亚洲AV无码精品色午夜| 国产成人久久激情91 | 99久久免费国产精精品| 亚洲国产天堂久久久久久| 久久亚洲精品视频| 亚洲午夜久久久久久久久电影网| 狠狠精品干练久久久无码中文字幕| 亚洲色大成网站WWW久久九九| 99久久精品免费看国产免费| 久久久久无码精品国产不卡| 久久久久99这里有精品10| 久久国产精品视频| 久久夜色精品国产亚洲| 久久夜色精品国产欧美乱| 亚洲中文字幕无码久久2017| 欧美色综合久久久久久| 久久精品免费网站网| 精品一区二区久久| 久久精品麻豆日日躁夜夜躁| 热re99久久6国产精品免费| 一本一道久久a久久精品综合| 伊人热人久久中文字幕| 中文字幕亚洲综合久久2| 91精品国产高清久久久久久91| 九九久久自然熟的香蕉图片| 久久人人爽人人爽人人AV东京热| 国产成人综合久久精品红| 模特私拍国产精品久久| 99久久免费国产精品特黄|