[LeetCode] Binary Tree Level Order Traversal II
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |
Question
Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree [3,9,20,null,null,15,7]
,
return its bottom-up level order traversal as:
本题难度Easy。
【复杂度】
时间 O(N) 空间 O(2^(h-1))
【思路】
与[LeetCode]Binary Tree Zigzag Level Order Traversal相似的处理,把每层的list
查到结果ans
的位置0上。
【代码】
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |