[Java program algorithm problem] Zilong game written test

Description:

  • Each question below is timed for 30 minutes.
  • When only part of the question is completed, it will be measured by time and difficulty of the question.

Topic A: String Combination

Enter any string containing English characters or numbers (the length does not exceed 20 characters), please Java programming to print all strings of English letters in different case combinations.
For example, when inputting "012e4s", output:
"012e4s", "012e4S", "012E4s", "012E4S".
For example, when "123" is input, output:
"123". For
example, when "AB" is input, output:
"ab", "aB", "Ab", "AB"
such as input "", the content is not output.

Topic B: Sorting a large number of characters

Enter a large number of English characters, please Java programming to achieve the fastest possible sorting algorithm. The lower time complexity is better. For example:
input ['a','p','p','l','e']
output ['a','e','l','p','p']
Note: Actual chars The content is all lowercase English characters, and the length is not more than 10MB.

public class Sort
{
    
    
    public static void sort(char[] chars)
    {
    
    
    }
}

Topic C: Classification

The game character has five attributes: strength, agility, endurance, intelligence, and luck, which together determine the character's ability tendency.
A certain role index has been entered. Please complete the find function in Java programming so that it can find another role in the role library that you think is the closest to the input role.

public class RoleData
{
    
    
    public float[] properties=new float[5];
}
public class RoleUtil
{
    
    
    public static RoleData find(List<RoleData> roleDataList,int inputRoleDataListIndex)
    {
    
    
        return null;
    }
}

Topic D: Virus transmission

President Rump is in a meeting in the Congress of a certain country. At this time, the seats form a two-dimensional matrix.
The new coronavirus can only spread between adjacent seats (either horizontally or vertically), and each transmission takes 1 minute.
Wearing a mask can be immune to the virus.
Assuming that any member of Parliament is infected with drugs, can he infect President Rump?
If it can be infected, how many minutes will it take at least?
Please complete the CoronaVirus class with Java programming so that the detect can detect the infection result:
 The detect function returns 0 to indicate that the Rump president will not be infected.
 The detect function returns other values ​​to indicate that it will be infected, and the shortest infection time (minutes) is calculated.
Note: The meaning of the contents of the map array:
• 0 means not wearing a mask
• 1 means wearing a mask
• 2 means not wearing a mask President Rump
• 3 means not wearing a mask and being infected with
drugs Note 2: The following are CoronaVirus categories:

public class CoronaVirus
{
    
    
    public static int detect(int[] map,int width,int height)
    {
    
    
        return 0;
    }
}

Below is the sample test code:

public class CoronaVirusTest
{
    
    
    public void test()
    {
    
    
        int[] map=new int[]{
    
    
            0,0,0,2,0,0,0,0,
            0,1,1,0,0,0,0,0,
            0,0,1,1,1,0,0,1,
            0,1,1,0,0,0,0,0,
            0,1,0,0,1,1,1,0,
            0,1,0,0,1,0,0,0,
            0,0,0,0,1,0,3,0,
            1,0,1,0,0,0,0,0,
        };
        int time=CoronaVirus.detect(map,8,8);
    }
}

Guess you like

Origin blog.csdn.net/qq_36045898/article/details/114069284