JAVAvivo2021届秋季校招笔试在线编程

Posted 爱做梦的鱼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JAVAvivo2021届秋季校招笔试在线编程相关的知识,希望对你有一定的参考价值。

目录

前言

兄弟们都会有offer的,不要慌,奥力给

一、游戏地图路径(没尝试,时间不够,我对最短路径问题不熟)

二、回文字符串(A0.8,逻辑混乱了)

package vivo;

import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author: 
 * @Email: 
 * @Date: 2020/9/12
 * @Time: 20:31
 * @Version: 1.0
 * @Description: Description
 */

/**
 * 1. 游戏地图路径
 * 2. 回文字符串
 * 3. 编译依赖问题
 */
public class Second 
    public static void main(String[] args) 
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        vaild(str);
        sc.close();
    

    public static void vaild(String s) 
        int low = 0, high = s.length() - 1;
        boolean flag1 = true;
        boolean flag2 =true ;
        while (low < high) 
            char c1 = s.charAt(low);
            char c2 = s.charAt(high);
            if (c1 == c2) 
                low++;
                high--;
             else 
                flag1 = true;
                flag2 = true;
                for (int i = low, j = high - 1; i < j; i++, j--) 
                    char c3 = s.charAt(i);
                    char c4 = s.charAt(j);
                    if (c3 != c4) 
                        flag1 = false;
                        break;
                    
                
                for (int i = low + 1, j = high; i < j; i++, j--) 
                    char c3 = s.charAt(i);
                    char c4 = s.charAt(j);
                    if (c3 != c4) 
                        flag2 = false;
                        break;
                    
                

                if (!flag2) 
                    System.out.println(s.substring(0, low) + s.substring(low + 1));
                    return;
                 else if (!flag1) 
                    System.out.println(s.substring(0, high) + s.substring(high + 1));
                    return;
                 else 
                    break;
                
            

        
        if (flag1 && flag2) 
            System.out.println(s);
         else 
            System.out.println("false");
        
    


三、编译依赖问题(全A)

package vivo;

import java.util.HashSet;
import java.util.Iterator;
import java.util.TreeMap;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author: 张志浩 Zhang Zhihao
 * @Email: 3382885270@qq.com
 * @Date: 2020/9/12
 * @Time: 21:41
 * @Version: 1.0
 * @Description: Description
 */
 
public class Third2 
    public static void main(String[] args) 
        System.out.println(new Third2().compileSeq("1,2,-1,1"));
    

    public String compileSeq(String input) 
        String[] strList = input.split(",");
        TreeMap<Integer, Integer> yiLai = new TreeMap<Integer, Integer>();
        for (int i = 0; i < strList.length; i++) 
            yiLai.put(i, Integer.parseInt(strList[i]));
        

        HashSet<Integer>[] lasts = new HashSet[2];
        lasts[0] = new HashSet<Integer>();
        lasts[1] = new HashSet<Integer>();
        int lastIndex = 0;
        lasts[lastIndex].add(-1);

        StringBuilder result = new StringBuilder();
        while (!yiLai.isEmpty()) 
            Iterator<Integer> iterator = yiLai.keySet().iterator();
            while (iterator.hasNext()) 
                int integer = iterator.next();
                if (lasts[lastIndex].contains(yiLai.get(integer))) 
                    result.append(integer);
                    result.append(",");
                    iterator.remove();
                    lasts[(lastIndex + 1) % 2].add(integer);
                
            
            lastIndex = (lastIndex + 1) % 2;
        
        return result.substring(0, result.length() - 1);
    

以上是关于JAVAvivo2021届秋季校招笔试在线编程的主要内容,如果未能解决你的问题,请参考以下文章

字节跳动正式启动2021届秋季校招

手把手教你写!字节跳动正式启动2021届秋季校招

美团2021届秋季校园招聘笔试-小美的区域会议——人工加入限制+树形dp

2022届互联网公司校招后端技术研发笔试

字节秋季笔试四道编程题(2021-09-12)

去哪儿网2017校招在线笔试(前端工程师)编程题及JavaScript代码