1.Title : The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)

P   A   H   N
A P L S I I G
Y   I   R

And then read line by line: "PAHNAPLSIIGYIR"

Write the code that will take a string and make this conversion given a number of rows:

string convert(string text, int nRows);

 convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR".

2.pseudocode : 

 creat data structure:
     the given number of rows  →  nRows;
     the given text string  →  s;
     stringBuffer[] to restore result  →  sb;
 set char position index i = 0;row position index j = 0;combing outcome index k = 1;
 while i < the length of s,then
     for each j from 0 to (nRows - 1)
         append the ith char of s to sb[j];
         i++;
     end
     for each j from (nRows - 2) to 1
         append the ith char of s to sb[j];
         i++;
     end
 end
 //form a united outcome
 for each k from 1 to (nRows - 1)
     append sb[k] to sb[0];
 end
 terminate and output sb[0];
 

pseudocode of zigzag conversion的更多相关文章

  1. 【leetcode❤python】 6. ZigZag Conversion

    #-*- coding: UTF-8 -*- #ZigZag Conversion :之字型class Solution(object):    def convert(self, s, numRow ...

  2. 64. ZigZag Conversion

    ZigZag Conversion The string "PAYPALISHIRING" is written in a zigzag pattern on a given nu ...

  3. No.006 ZigZag Conversion

    6. ZigZag Conversion Total Accepted: 98584 Total Submissions: 398018 Difficulty: Easy The string &qu ...

  4. leetcode第六题 ZigZag Conversion (java)

    ZigZag Conversion The string "PAYPALISHIRING" is written in a zigzag pattern on a given nu ...

  5. leetcode题解 6.ZigZag Conversion

    6.ZigZag Conversion 题目: The string "PAYPALISHIRING" is written in a zigzag pattern on a gi ...

  6. 6.[leetcode] ZigZag Conversion

    The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like ...

  7. 字符串按照Z旋转90度然后上下翻转的字形按行输出字符串--ZigZag Conversion

    The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like ...

  8. LeetCode--No.006 ZigZag Conversion

    6. ZigZag Conversion Total Accepted: 98584 Total Submissions: 398018 Difficulty: Easy The string &qu ...

  9. leetcode-algorithms-6 ZigZag Conversion

    leetcode-algorithms-6 ZigZag Conversion The string "PAYPALISHIRING" is written in a zigzag ...

随机推荐

  1. 201521123034《Java程序设计》第七周学习总结

    1. 本周学习总结 以你喜欢的方式(思维导图或其他)归纳总结集合相关内容. 2. 书面作业 ArrayList代码分析 1.1 解释ArrayList的contains源代码 答:从ArrayList ...

  2. Mysql中的in和find_in_set的区别?

    在mysql中in的使用情况如下: select * from article where 列名 in(值1,值2,值3.....): select * from article where 值1 i ...

  3. Oracle与Mysql区别简述

    在Mysql中,一个用户下可以创建多个库: 而在Oracle中,Oracle服务器是由两部分组成 数据库实例[理解为对象,看不见的] 数据库[理解为类,看得见的] 一个数据库实例可拥有多个用户,一个用 ...

  4. Maven第四篇【私有仓库、上传jar包、引用私服jar包、上传本地项目到私服】

    搭建私有服务器 前面已经说过了,我们使用Maven的使用,如果需要导入相对应的jar包,Maven首先会在我们的本地仓库中寻找->私有仓库->中心仓库- 然而,我们的本地仓库常常没有想要的 ...

  5. 详解go语言的array和slice 【二】

    上一篇已经讲解过,array和slice的一些基本用法,使用array和slice时需要注意的地方,特别是slice需要注意的地方比较多.上一篇的最后讲解到创建新的slice时使用第三个索引来限制sl ...

  6. 【译】The Accidental DBA:Troubleshooting

    最近重新翻看The Accidental DBA,将Troubleshooting部分稍作整理,方便以后查阅.此篇是Part 3Part 1:The Accidental DBA:SQL Server ...

  7. Java多线程Runnable与Callable区别与拓展

    我们先来分别看一下这两个接口 Runnable: // // Source code recreated from a .class file by IntelliJ IDEA // (powered ...

  8. win7系统Myeclipse下切换SVN用户

     Eclipse的SVN插件Subclipse做得很好,在svn操作方面提供了很强大丰富的功能.但到目前为止,该插件对svn用户的概念极为淡薄,不但不能方便地切换用户,而且一旦用户的帐号.密码保存之后 ...

  9. 一张图告诉你移动Web前端所有技术(工程化、预编译、自动化)

    你要的移动web前端都在这里! 大前端方向:移动Web前端.Native客户端.Node.js. 大前端框架:React.Vue.js.Koa 跨终端技术:HTML5.CSS 3.JavaScript ...

  10. scoke摘要

      登录|注册     关闭 永不磨灭的意志 /* ----------------500G的电影拷到了U盘上,U盘的重量会不会增加?----------------------*/       目录 ...