思路: 使用两个队列(一个可以顺序读,所以用vector模拟),每个队列放一层结点。
题解: 两种方法: 1. 使用栈: O(n) Time, O(n) Space。 2. Morris traversal (构造线索树), O(n) Time, O(1) Space.
分类:
其他好文 时间:
2014-08-27 20:16:18
阅读次数:
227
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 ...
分类:
其他好文 时间:
2014-08-25 23:00:25
阅读次数:
671
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 ...
分类:
其他好文 时间:
2014-08-25 22:27:24
阅读次数:
315
class Solution {public: string convert(string s, int nRows) { int len = s.length(); if (len cols; int si = 0; int ri =...
分类:
其他好文 时间:
2014-08-17 21:21:32
阅读次数:
218
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 ...
分类:
其他好文 时间:
2014-08-17 18:25:02
阅读次数:
233
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 ...
分类:
其他好文 时间:
2014-08-17 13:09:52
阅读次数:
168
Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al...
分类:
其他好文 时间:
2014-08-16 00:59:49
阅读次数:
179
Pixel ? Point Conversion
Table...
分类:
其他好文 时间:
2014-08-13 19:00:00
阅读次数:
373
在 clean project 后,并没有报错,但是在'Run as Android Application' 的时候就会报出这样的错。1 Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files de...
分类:
其他好文 时间:
2014-08-13 00:27:34
阅读次数:
320
题目:
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: "PAHNAPLSIIG...
分类:
其他好文 时间:
2014-08-12 00:47:43
阅读次数:
196