金山云暑期实训笔试 2023/6/20 19:00


第一题

image-20230620204643083

AC代码

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();

        String[] words = input.split(" ");
        StringBuilder result = new StringBuilder();

        String prevWord = "";
        for (String word : words) {
            if (!word.equalsIgnoreCase(prevWord)) {
                result.append(word).append(" ");
                prevWord = word;
            }
        }

        String output = result.toString().trim();
        System.out.println(output);
    }
}

第二题

image-20230620204826489

image-20230620204755520

ACM模式下构建二叉树来实现各个核心代码


  目录