java面试——2021字节跳动校招提前批后端工程师笔试以及解答

    技术2025-07-23  13

    1面试的总结的经验是对输入和输出的IO模板要熟悉

    2输出的结果的运行

    3

    1假定操作系统是采用的是32位整数的为进程号的。当创建新的进程的时候需要找到最小的未使用的是进程ID

    输入:

    一行是表示的n 不超过是2^20

    接下来是的n中已经存在的id正整数的2^31 不保证排序

    输入实例:

    5

    1

    2

    3

    4

    6

    输出结果:

    5

    /** * Copyright (C), 2018-2020 * FileName: Main * Author: xjl * Date: 2020/7/4 14:55 * Description: 测试案例 */ package IO_Template; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { int test = test(); System.out.println(test); } public static int test() { Scanner sc = new Scanner(System.in); //输入的第一行 int n = sc.nextInt(); sc.nextLine(); int result = 1; ArrayList<Integer> list = new ArrayList<>(); //存放数据 for (int i = 0; i < n; i++) { int num = sc.nextInt(); list.add(num); } //寻找结果 for (int i = 1; i <= n; i++) { if (!list.contains(i)) { return i; } } return 0; } }

    2 输入一个字符串首位相连,身为一个环 问是否能从一个切点中的切断后产生一个回文 ,可以的话输出Yes 否则是输出No

    输入:字符串

    输入的实例:aab

    输出:Yes

    public static void test1() { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { //输入 String str = sc.nextLine(); //处理 boolean result = ishiuwen(str); //输出 if (result) { System.out.println("Yes"); } else { System.out.println("No"); } } } private static boolean ishiuwen(String str) { int length = str.length(); String result = str + str; for (int i = 0; i < length; i++) { String s = result.substring(i, i + length); if (ishiu(s)) { return true; } } return false; } private static boolean ishiu(String s) { int start = 0; int end = s.length() - 1; while (start <= end) { if (s.charAt(start) != s.charAt(end)) { return false; } start++; end--; } return true; }

    3输入一个整数  把一个每位数组拆开,然后组合成为其他的数据,并在这里集合中的找到一个比n小的,但是是集合红的最大的一个数据 比如:15234 可以拆分为 1 2 3 4 5 然后组合比15234要小的数组就 但是集合中最大的一个 如果不存在输入Not found

    输入实例:

    153

    输出135

    11

    Not Found

     

    Processed: 0.013, SQL: 9