3.25面试简单复盘

1.手写代码水仙花数(input 100<=m<n<=999).

	private static void print(int m, int n) {
    
    
       for (int i = m; i <= n; i++) {
    
    
           int a = i / 100;
           int b = (i % 100) / 10;
           int c = i % 10;
           int total = (int) (Math.pow(a, 3) + Math.pow(b, 3) + Math.pow(c, 3));
           if (total == i) {
    
    
               System.out.println(i);
           }
       }
	}

2.SQL语句,保留相同邮箱最后注册的人.

delete
from test.person
where id not in (select exist
                 from (select max(id) as exist from test.person group by email) as tmp);

3.秒杀系统的优化.
我个人认为用 mq 削峰,然后直接消费固定数量,最后持久化数据库.

猜你喜欢

转载自blog.csdn.net/hexiaodiao/article/details/115221939