华为4.26笔试

import java.util.Scanner;

public class Main3 {

    //
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int start = input.nextInt();
        int end = input.nextInt();
        int[] e = new int[100000];
        int[] next =new int[100000];
        int j=1;
        int gap=end-start+1;

        e[0]=-1;
        next[0]=1;
        for(;j<=end-start+1;j++){
               e[j]=j;
               next[j]=e[j]+1;
        }
        e[gap]=gap;
        next[gap]=-1;
        int bottom = gap;


        int opsize = input.nextInt();
        while (opsize-->0){
            int op = input.nextInt();
            if(op==1){
                int o1=input.nextInt();
                next[0]=next[next[0]];

            }else if(op==2){

                int value=input.nextInt();
                next[value-1]=next[value];


            }else{//op=3
                int relive=input.nextInt();
                e[bottom+1]=relive;
                next[bottom]=e[bottom+1];
                next[bottom+1]=-1;
                bottom++;
            }
        }

        System.out.println(e[next[0]]);
    }

}

太气了

第二题感觉超简单,但是没想到测试数据挺大的,一开始没好好模拟链表,超时了,后来数组模拟链表完发现已经自动交卷了

第二题这样应该没问题呢吧

#华为##华为信息集散地#
全部评论
第二题图灵来了也A不了
点赞 回复 分享
发布于 2023-04-27 21:31 广东
Scanner超时
点赞 回复 分享
发布于 2023-04-26 21:41 重庆
你提交了吗?第二题大家都是超时
点赞 回复 分享
发布于 2023-04-26 21:36 陕西
服了第2题
点赞 回复 分享
发布于 2023-04-26 21:30 北京
试了scanner第一个数直接输出就超时
点赞 回复 分享
发布于 2023-04-26 21:20 香港

相关推荐

评论
1
5
分享

创作者周榜

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