Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and ...
分类:
其他好文 时间:
2017-06-18 23:40:34
阅读次数:
295
题目: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level ...
分类:
编程语言 时间:
2017-06-15 14:17:51
阅读次数:
188
ZigZag Conversion : The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this patt ...
分类:
其他好文 时间:
2017-06-13 14:17:07
阅读次数:
155
https://leetcode.com/problems/zigzag-conversion/ 水题纯考细心 题目:依照Z字形来把一个字符串写成矩阵,然后逐行输出矩阵。 O(n)能够处理掉 记i为行数 第0行和第numRow-1行。 ans += str[i+k*(numRows*2-2)], k ...
分类:
其他好文 时间:
2017-06-12 23:55:14
阅读次数:
195
问题的大意就是将字符串中的字符按锯齿状(倒N形)垂直由上向下放置,最后水平从左向右读取。比如 ABCDEFGHIJKLMN,4表示 A G M B F H L N C E I K D J 按水平顺序读取的结果则为AGMBFHLNCEIKDJ。(原题目的描述就很有问题) 解决方案非常简单,可以发现字符 ...
分类:
其他好文 时间:
2017-06-09 22:40:01
阅读次数:
139
题目: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level ...
分类:
其他好文 时间:
2017-06-06 10:34:48
阅读次数:
252
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 ...
分类:
编程语言 时间:
2017-06-04 00:21:55
阅读次数:
195
原题 Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level a ...
分类:
其他好文 时间:
2017-05-25 13:36:46
阅读次数:
154
一、Description: 二、Solutions: 1、思路: 首先想到按照行来进行添加字符。发现第一行与最后一行位移量为 (numRows-1) * 2; 中间行的第奇数个字符的位移量为上面部分 ,即 step = (numRows-1-j) * 2, 第偶数个字符的位移量为下面部分, 即 2 ...
分类:
其他好文 时间:
2017-05-25 11:56:22
阅读次数:
154
1 public String convert(String s, int numRows) { 2 if(numRows == 1) return s; 3 StringBuilder str = new StringBuilder(""); 4 char[] ch = s.toCharArray... ...
分类:
其他好文 时间:
2017-05-15 22:24:55
阅读次数:
182