public List<Integer> rightSideView(TreeNode root) {
		List<Integer> ret = new ArrayList<Integer>();
		if (root == null)
			return ret;
		LinkedList<TreeNode> cur = new LinkedList<TreeNode>();
		cur.addLast(root);
		while (cur.size() != 0) {
			ret.add(cur.getLast().val);
			LinkedList<TreeNode> next = new LinkedList<TreeNode>();
			for (TreeNode node : cur) {
				if (node.left != null)
					next.addLast(node.left);
				if (node.right != null)
					next.addLast(node.right);
			}
			cur = next;
		}
		return ret;
	}