114. 二叉树展开为链表Difficulty: 中等给定一个二叉树,将它展开为链表。例如,给定二叉树 1 / \ 2 5 / \ \3 4 6将其展开为:1 \ 2 \ 3 \ 4 \ 5 \ 6思路:* 思路:* 前序遍历+递归。* 递归函数处理逻辑:* 1.将当前节点的右子树节点保存。* 2.将右子树指针指向左子树(现在左右子树指针都指向同一个)* 3.将右子树的最右子节点的右指针指向原来的左子树。SolutionLanguage: Java/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { public void flatten(TreeNode root) { if(root == null) { return ; } TreeNode rightNode = null; //保
………………………………