携程2022年春招实习笔试经验~

在3月10日晚7:00 - 9:00期间参加了携程的笔试考试,这也是第一次参加这种类型的笔试,所以在这总结一下经验吧,之后可以按照这个经验再积极准备别的厂的面试。

个人面试感觉应该是无了,就是不知道携程有没有感谢信,先等一手

首先题型上:往年携程是20 + 3的模式(20道选择题,3道编程题),今年改成了4道编程题,限时两个小时。

第一道是一个数组的规划问题,要求是运算符号两边要格式化,改成只有一个空格的格式化输出模式,用例如下所示:

用例1:dasds <      sadasda
用例2: w < v
用例3: fsfsdfsdf> sadas

第二道题是一个不算很难的数组相乘问题,但是我考虑的过于麻烦😂,倒是在这个题目上面花费了相当多的时间,大概意思是: 一个孩子,上课没有听课,因此他理解的乘法是这样的

1 2 3

3 2 1

——

1 2 3

2 4 6

3 6 9

——

7 3 8

然后要求的输入用例为:

3

123 321

111

100 21

这个题目的解法还算是比较简单,只要将一个数字分离开来,比如将321分成arrays[0] = 3 arrays[1] = 2 arrays[2] = 1

然后依次与第一个操作数相乘,再相加到一起即可完成要求:


第三题不记得了,哈哈哈,因为属实没啥思路,就直接跳过了~


然后第四题的话是一个回文数的问题,这个题因为卡在了最后的时限,所以导致没能提交成功,(应该是系统卡了,我在本地IDE上运行速度还是挺快的),因此直接将答案贴在这里,感兴趣大家可以去了解一下~

import java.util.Scanner;

public class Question4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String[] strings = str.split(" ");
        int a = Integer.parseInt(strings[0]);
        int b = Integer.parseInt(strings[1]);

        str = scanner.nextLine();
        strings = str.split(" ");
        int year = Integer.parseInt(strings[0]);
        int mounth = Integer.parseInt(strings[1]);
        int day = Integer.parseInt(strings[2]);

        int result = combinData(year,mounth,day);

        while(isAimedNumber(result) != true){
            day = day + 1;
            if(day > b){
                mounth++;
                day = 1;
            }
            if(mounth > a){
                year++;
                mounth = 1;
            }

            result = combinData(year,mounth,day);
        }

        int tempA = result;
        int gridB = 1;
        for(int i = 0 ; i < highestNum(mounth) + highestNum(day) ; i++){
            tempA = tempA / 10;
            gridB = gridB * 10;
        }

        year = tempA;

        int tempB = result;
        tempB = tempB % gridB;
        tempB /= 10;
        mounth = tempB;

        day = result % 10;

        System.out.println(year + " " + mounth + " " + day);
    }

    //把年月日组合到一起
    private static int combinData(int year, int mounth, int day){
        int result = 0;
        for(int i = 0 ; i < highestNum(mounth) + highestNum(day) ; i++){
            year = year * 10;
        }
        result = result + year;

        for(int i = 0 ; i < highestNum(day) ; i++){
            mounth = mounth * 10;
        }

        result = result + mounth + day;
        return result;
    }

    //把年月日拆分开

    //计算数字的最高位
    private static int highestNum(int a){
        int result = 0;
        while(a / 10 > 0){
            result++;
            a = a / 10;
        }
        return result + 1;
    }

    //判断该数字是否为回文数字
    private static boolean isAimedNumber(int temp){
        if(temp < 0 || (temp % 10 == 0 && temp!= 0)){
            return false;
        }

        int revertedNumber = 0;
        while(temp > revertedNumber){
            revertedNumber = revertedNumber * 10 + temp % 10;
            temp /= 10;
        }

        return temp == revertedNumber || temp == revertedNumber / 10;
    }
}
全部评论

相关推荐

07-14 13:47
门头沟学院 Java
Lynn012:你评估好自己的位置了吗《顶尖应届》
投递小米集团等公司7个岗位
点赞 评论 收藏
分享
点赞 评论 收藏
分享
来个厂收我吧:首先,市场侧求职我不是很懂。 但是,如果hr把这份简历给我,我会觉得求职人不适合做产品经理。 问题点: 1,简历的字体格式不统一,排版不尽如人意 2,重点不突出,建议参考star法则写个人经历 3,印尼官方货币名称为印度尼西亚卢比(IDR),且GMV690000印尼盾换算为305人民币,总成交额不高。 4,右上角的意向职位在发给其他公司时记得删除。 5,你所有的经历都是新媒体运营,但是你要投市场营销岗位,jd和简历不匹配,建议用AI+提示词,参照多个jd改一下经历内容。 修改建议: 1,统一字体(中文:思源黑体或微软雅黑,英文数字:time new romans),在word中通过表格进行排版(b站学) 2,校招个人经历权重:实习经历=创业经历(大创另算)>项目经历>实训经历>校园经历 3,请将项目经历时间顺序改为倒序,最新的放最上方。 4,求职方向不同,简历文字描述侧重点也需要不同。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务