【度小满】面经

手撕代码:镜像二叉树

import java.util.Scanner;
class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;
    TreeNode(int val){
        this.val = val;
    }
}
class Solution{
    public TreeNode reverse(TreeNode root) {
        if (root == null) {
            return null;
        }
        TreeNode tem = root.left;
        root.left = root.right;
        root.right = tem;
        reverse(root.left);
        reverse(root.right);
        return root;
    }
}
class Pri{
    public TreeNode printall (TreeNode root) {
        if (root == null) {
            return null;
        }
        System.out.println(root.val);
        printall(root.left);
        printall(root.right);
        return root;
    }
}
public class Main {
    public static void main(String[] args) {
        //Scanner in = new Scanner(System.in);
        //int a = in.nextInt();
        //System.out.println(a);
        TreeNode root = new TreeNode(4);
        TreeNode root1 = new TreeNode(2);
        TreeNode root2 = new TreeNode(7);
        TreeNode root3 = new TreeNode(1);
        TreeNode root4 = new TreeNode(3);
        TreeNode root5 = new TreeNode(6);
        TreeNode root6 = new TreeNode(9);
        root.left = root1;
        root.right = root2;
        root1.left = root3;
        root1.right = root4;
        root2.left = root5;
        root2.right = root6;
        
        Solution s = new Solution();
        s.reverse(root);
        Pri p = new Pri();
        p.printall(root);
    }
}

问的都是java的知识:

equal如何重写,会怎么等?

static、final、this、super的区别

ArrayList 和 LinkedList的区别

说一说HashMap

说一说String、StringBuffer、StringBuilder的区别

说一说abstract和interferce的区别

说一说TCP/UDP五层模型???我就知道七层...被面试官嘲笑了???

(应用层、传输层、网络层、数据链路层、物理层)

说一说七层网络每一层都是干嘛的?

说一说JVM

说一说线程的实现方式

说一说垃圾回收机制

以后要多背java试题!!!

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值