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 ...
分类:
其他好文 时间:
2018-12-29 11:09:36
阅读次数:
121
https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ Given a binary tree, return the zigzag level order traversal of its nodes' val ...
分类:
其他好文 时间:
2018-12-18 22:40:22
阅读次数:
176
https://leetcode.com/problems/zigzag-conversion/ The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you ...
分类:
其他好文 时间:
2018-12-05 14:26:23
阅读次数:
160
Given two 1d vectors, implement an iterator to return their elements alternately. Example: Follow up: What if you are given k 1d vectors? How well can ...
分类:
其他好文 时间:
2018-11-29 15:18:56
阅读次数:
160
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 ...
分类:
其他好文 时间:
2018-11-06 01:00:28
阅读次数:
303
ZigZag显示字符串 Golang 收获 1. []string 格式可以通过strings.Join([]string, "")转换成str格式 2. 开始的时候想到的是数组的解决办法, 随后想到可以用map的方式+string的方式进行追加; 3. numRows作为输入,需要转换理解为N R ...
分类:
其他好文 时间:
2018-11-05 22:23:37
阅读次数:
116
"题面在这里" 思路: 如果直接去连边然后跑最小生成树的话,不难发现边数是$O(nq)$级别的。 于是我们可以观察一下这一张图: 不难发现每次添加的边是相邻的两个点之间互相连边,并且很重要的是,边权一次一次地变大。 考虑Kruskal的过程,如果有两条边$(u_1,v_1,w_1),(u_2,v_2 ...
分类:
其他好文 时间:
2018-11-04 12:35:06
阅读次数:
225
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 ...
分类:
其他好文 时间:
2018-10-05 13:56:45
阅读次数:
151
一、题目 1、审题 2、分析 给出一棵二叉树,以“之"字形层序输出二叉树的结点值。 二、解答 1、思路: 方法一、 采用一个队列进行层次遍历,遍历每一层时,将每一层结点放入一个数组,用一个标志 flag 记录向左或向右的访问顺序,并将符合的层次的结点访问顺序记录在 List 中。 方法二、 采用递归 ...
分类:
其他好文 时间:
2018-09-30 14:48:19
阅读次数:
164
1、两数之和:给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。 2、两数相加:给定两个非空链表来表示两个非负整数。位数按照逆序方式存储,它们的每个节点只存储单个数字。将两数相加返回一个新的链表。 3、无重复字符的最长子串:给定一个字符串,找出不含有重复字符的最长子串的长度。 4、两个排序 ...
分类:
其他好文 时间:
2018-09-29 20:26:37
阅读次数:
130