美团一面复活赛4/18

语言表述还是有问题。。fuck

1.自我介绍

2.项目中遇到哪些问题,怎么解决的

太菜了没答好。。面试官没为难(购票扣减逻辑要复习一下)

3.mq发生了数据积压怎么去解?

面试官感觉我不会,也没为难我

4.Integer=20 Integer=200

5.深拷贝浅拷贝

6.多层内部类深拷贝怎么做(提示socket,序列化反序列化)

import java.io.*;

class Outer implements Serializable {
    int outerField;
    Inner inner;

    Outer(int outerField, int innerField) {
        this.outerField = outerField;
        this.inner = new Inner(innerField);
    }

    // Inner class
    class Inner implements Serializable {
        int innerField;

        Inner(int innerField) {
            this.innerField = innerField;
        }
    }

    // Method to perform deep copy
    public Outer deepCopy() throws IOException, ClassNotFoundException {
        // Write the object to a byte array
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(bos);
        out.writeObject(this);

        // Read the object from the byte array
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        ObjectInputStream in = new ObjectInputStream(bis);
        return (Outer) in.readObject();
    }
}

public class DeepCopyExample {
    public static void main(String[] args) {
        try {
            // Creating an Outer object
            Outer original = new Outer(10, 20);
            System.out.println("Original object: " + original.outerField + ", " + original.inner.innerField);

            // Performing deep copy
            Outer copied = original.deepCopy();
            System.out.println("Copied object: " + copied.outerField + ", " + copied.inner.innerField);
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}


 

在这个示例中,Outer类包含一个内部类Inner。通过实现Serializable接口,可以将Outer和Inner类序列化。在deepCopy方法中,通过对象输出流将对象写入字节流,然后通过对象输入流从字节流中读取对象,最终返回深拷贝的对象。

7.subList()用过吗

说没用过,跳过这个问题了,也没为难我,泪目。。。

8.hashset存对象比较是否相等

9.hashcode,equals判断逻辑

10.线程池

11.写一个单例模式(没学。。cao)

public class Singleton {
    // 私有静态成员变量,用于保存唯一实例
    private static Singleton instance;

    // 私有构造函数,防止外部通过new关键字实例化对象
    private Singleton() {
    }

    // 公有静态方法,用于获取唯一实例
    public static Singleton getInstance() {
        // 懒汉式单例模式,延迟实例化,只有在需要时才创建实例
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }

    // 其他方法...
}
 

12.算法:定义出链表的数据结构,判断链表是否有环

13.题

环形公路 有4个加油站 ,判断车能否从某个加油站开始绕着环形公路走一圈,如果能,从哪个节点开始能走一圈,要求求出所有的站点。要求时间复杂度O(n),循环一次解决。

每个点加的油为gas【a】gas【b】gas【c】gas【d】

到达某个点耗油为cost【a】cost【b】cost【c】cost【d】

fuck 原来是leetcode上的题

134. 加油站 - 力扣(LeetCode)

14.数学题四个人(A、B、C、D)晚上过桥,并且只有一个手电筒,每次只能过两个人,并且还需要有一个人回来传递手电_百度知道 (baidu.com)

相关推荐

  1. 321——一面

    2024-04-26 09:48:01       42 阅读
  2. 面试(一面

    2024-04-26 09:48:01       31 阅读
  3. 【面经】3月29日 /平台/后端/一面/1h

    2024-04-26 09:48:01       37 阅读
  4. 到店-后端开发一面

    2024-04-26 09:48:01       41 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-26 09:48:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-26 09:48:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-26 09:48:01       87 阅读
  4. Python语言-面向对象

    2024-04-26 09:48:01       96 阅读

热门阅读

  1. Python内置函数input()详解

    2024-04-26 09:48:01       29 阅读
  2. 如何理解三次握手四次挥手

    2024-04-26 09:48:01       34 阅读
  3. 如何一键清除文件目录下所有的node_modules

    2024-04-26 09:48:01       28 阅读
  4. 工厂方法模式(模拟发奖多种商品)

    2024-04-26 09:48:01       33 阅读
  5. Elasticsearch索引别名:管理与优化数据访问

    2024-04-26 09:48:01       38 阅读
  6. log4j:WARN No appenders could be found for logger

    2024-04-26 09:48:01       34 阅读
  7. Ubuntu离线安装g++、locales

    2024-04-26 09:48:01       30 阅读
  8. Circuits--Sequential--Finite_2

    2024-04-26 09:48:01       30 阅读
  9. centos7 宝塔php7安装mongodb扩展

    2024-04-26 09:48:01       33 阅读