题目
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 ...
分类:
其他好文 时间:
2014-06-24 23:59:25
阅读次数:
338
Description:Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next ...
分类:
其他好文 时间:
2014-06-14 18:41:40
阅读次数:
265
一道数学题,参考了网上的思路,先计算一下每一个zig包含的字符个数,实际上是zigSize =
nRows + nRows –
2然后一行一行的加s中的特定元素就行。第一行和最后一行都只需要加一个字符,每一个zig,而且在s中的index间隔是zigSize。中间每一行需要添加两个字符到结果中去。第...
分类:
其他好文 时间:
2014-06-13 08:32:52
阅读次数:
264
题目
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 alternate between).
For example:
G...
分类:
其他好文 时间:
2014-06-08 17:29:07
阅读次数:
315
题目:convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR".
解题思路:这个是个纯粹找规律的题,其他没啥特殊的。下面的例子nRows=4;
找规律按照数组小标开始,寻找下标出现的规律,
1. 第一行和最后一行相邻元素下标之差为 2*nRows-2;
2. 除过第一行和最后一行,其余行要多一个元素,该元素出现的下标和行号有关,比如5 = 1 + 6 - 2,可以总结出规律为 j + 2*nRows-2 - 2*i;
关于 i 和 j 看以看下面...
分类:
其他好文 时间:
2014-06-08 09:11:57
阅读次数:
230
1、Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
clas...
分类:
其他好文 时间:
2014-06-02 23:13:22
阅读次数:
290
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-05-24 04:13:54
阅读次数:
284
题目链接 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 ...
分类:
其他好文 时间:
2014-05-22 01:55:19
阅读次数:
320
题目:
zigzag,就是锯齿状的数字顺序,其形式就是首尾行间断的比内部行少一个,就是下面的形式。
1 * 7
2 6 8 12
3 5 9 11
4 * 10
更好看点就是
1 7
2 ...
分类:
其他好文 时间:
2014-05-19 22:43:12
阅读次数:
373
1、
??
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 pattern in a fixed font for better legibili...
分类:
其他好文 时间:
2014-05-18 07:56:49
阅读次数:
407