当前位置: 首页 > news >正文

青岛网站设计选哪家猪八戒网兼职接单

青岛网站设计选哪家,猪八戒网兼职接单,net快速建站,湖南人文科技学院招聘给定一个二叉树#xff0c;返回它的中序 遍历。 示例: 输入: [1,null,2,3] 1 \ 2 / 3 输出: [1,3,2] 进阶: 递归算法很简单#xff0c;你可以通过迭代算法完成吗#xff1f; 递归 /*** Definition for a binary tree node.* public class TreeNode … 给定一个二叉树返回它的中序 遍历。 示例: 输入: [1,null,2,3]    1     \      2     /    3 输出: [1,3,2] 进阶: 递归算法很简单你可以通过迭代算法完成吗 递归 /*** Definition for a binary tree node.* public class TreeNode {* int val;* TreeNode left;* TreeNode right;* TreeNode(int x) { val x; }* }*/ class Solution {public List Integer inorderTraversal(TreeNode root) {List Integer res new ArrayList ();helper(root, res);return res;}public void helper(TreeNode root, List Integer res) {if(root null)return;helper(root.left, res);res.add(root.val);helper(root.right, res);} } 压栈 public class Solution {public List Integer inorderTraversal(TreeNode root) {List Integer res new ArrayList ();Stack TreeNode stack new Stack ();TreeNode curr root;while (curr ! null || !stack.isEmpty()) {while (curr ! null) {stack.push(curr);curr curr.left;}curr stack.pop();res.add(curr.val);curr curr.right;}return res;} } morris 虽然是空间O(1),但是oj并没有测出来效果依旧空间只超过40% /*** Definition for a binary tree node.* public class TreeNode {* int val;* TreeNode left;* TreeNode right;* TreeNode(int x) { val x; }* }*/ class Solution {public List Integer inorderTraversal(TreeNode root) {List Integer res new ArrayList ();TreeNode curr root;TreeNode pre;while (curr ! null) {if (curr.left null) {res.add(curr.val);curr curr.right; // move to next right node} else { // has a left subtreepre curr.left;while (pre.right ! null) { // find rightmostpre pre.right;}pre.right curr; // put cur after the pre nodeTreeNode temp curr; // store cur nodecurr curr.left; // move cur to the top of the new treetemp.left null; // original cur left be null, avoid infinite loops}}return res;} }
http://www.zqtcl.cn/news/680502/

相关文章:

  • 贵阳手机网站建设公司沈阳图书设计公司
  • 哪里做网站比较好在哪里注册域名
  • 做搜狗pc网站软件下载广告设计与制作学什么
  • 软件工程 旅游网站开发er图昆山网站建设网站建设
  • 网站下载的网页修改下面版权所有企业建设营销型网站的目的有
  • 官方重大项目建设库网站手机ps软件如何做ppt下载网站
  • 全国加盟网站大全海尔网站建设目标
  • wordpress 企业站模版自己做视频网站可以吗
  • 建设电子商务网站的方法有广东网站开发收费
  • php网站页面转wordpress网站广告代码
  • 在线网站建设教程网站版面布局结构
  • 网站建设提议网站建设怎么在图片上加字
  • 网站模板但没有后台如何做网站家政网站开发
  • 自己办网站审批流程网页设计师的发展路径
  • 什么叫网站地图百度竞价排名费用
  • 企业网站建设顾问wordpress如何用API采集
  • win7网站后台无法编辑vr网站建设
  • 做头发个人网站制作素材dw中做网站的步骤
  • 学校网站做几级等保网页制作与维护
  • 十堰外贸网站建设松滋做网站
  • 网站导航条青浦徐泾网站建设
  • 厦门网站建设一般多少钱店铺域名是什么意思
  • 网站关键词搜索排名怎么做雅奇小蘑菇做网站好不好用
  • 手机网站案例建设网站地图素材
  • 企业网站制作比较好的如何设计一个网页首页代码
  • 维护网站成本网站建设进度图
  • asp.net做织梦网站设计手机网站建设
  • 江苏省住房和城乡建设局网站首页北京大型网站制作公司
  • 网站改版工作方案网站设计技能培训
  • 佳木斯市网站建设淄博网站开发招聘