1
# Runtime: 69 ms (Top 15.25%) | Memory: 14.3 MB (Top 28.85%)2
# Definition for a binary tree node.3
# class TreeNode(object):4
# def __init__(self, val=0, left=None, right=None):9
def verticalTraversal(self, root):12
:rtype: List[List[int]]17
col, row, node = q.pop()18
l.append((col, row, node.val))20
q.append((col - 1, row + 1, node.left))22
q.append((col + 1, row + 1, node.right))26
ans.append([l[0][-1]])27
for i in range(1, len(l)):28
if l[i][0] > l[i - 1][0]:29
ans.append([l[i][-1]])31
ans[-1].append(l[i][-1])