Netease 2021 test and development engineer programming questions collection and arrangement (1)

1. Xiaoyi got a string containing only uppercase and lowercase English characters, which may not be a palindrome. Xiaoyi can add any number of arbitrary characters at the end of the string to turn the string into a palindrome. Now, please write a program that can calculate the shortest palindrome that Xiaoyi can get.
Input description:
One line includes a string s, 1<=|s|<= 1 0 3 10^3103 .
Output description:
One line contains a string representing the answer.
Example 1:
Input: noon
Output: noon
Example 2:
Input: noo
Output: noon
Example 3:
Input: helloworld
Output: helloworldlrowolleh

2. Niu Niu now has an array a containing n positive integers. Niu Niu can split each number a[i] into several positive integers whose sum is a[i]. Niu Niu wants to know after the split (also possible A number is not split) How many prime numbers can this array have at most?
Input description: In the
first line, a positive integer n represents the length of the array. In the
second line, n positive integers represent the value of a[i]
1<=n<=1e6,1<=a[i]<=1e9
Output description:
After splitting The maximum number of prime numbers in the array
Example 1 :
Input:
3
1 1 1
Output:
0
Example 2:
Input:
3
5 3 7
Output:
6

3. Now there are n people queuing to buy tickets. It is known that they will start selling tickets at 8 o'clock in the morning. There are two ways for these n people to buy tickets: The first is that everyone can buy their own tickets individually, and the i-th person spends a[i] seconds. The second is that everyone can choose to buy tickets with the people behind him. The i-th person and the i+1-th person spend a total of b[i] seconds. The last person can only buy tickets with the person in front or alone. Since the place where the ticket is sold wants to close earlier, it wants to know the earliest time it can close the door. Please output a time format like: 08:00:40am/pm. The
time number should be two digits. If it is over in the morning, it is am , The end of the afternoon is PM
input description:
input an integer T in the first line, and then there are T groups of test data.
For each set of test data: enter a number n, which means there are n people buying tickets.
The next n numbers represent the time a[i] when each person buys a ticket individually.
The next n-1 number represents the time it takes for each person to buy tickets with the person in front of him b[i]
1<=T<=100
1<=n<=2000
1<=a[i]<= 50
1<=b[i]<=50
Output description:
For each group of data, output a time, which represents the time of closing the door.
Example 1:
Input:
2
2
20 25
40
1
8
Output:
08:00:40 am
08:00 :08 am

4. Now there are n items, and each item has a value. Now I want to distribute these items to two people. The total value of the items allocated by each of these two people is required to be the same (the number can be different, and the total value is the same That's it), the remaining items need to be thrown away, and now I want to know the minimum value of items needed to meet the requirements and distribute them to two people.
Input description:
Input an integer T in the first line, which means there are T groups of test data.
For each set of test data, enter an integer n in one line, which represents the number of items.
Next n numbers, a[i] represents the value of each item.
1<=T<=10
1<=n<=15
1<=a[i]<=100000
Output description:
For each set of test data, output an answer to represent the minimum value needed.
Example 1:
Input:
1
5
30 60 5 15 30
Output:
20

Guess you like

Origin blog.csdn.net/qq_34124009/article/details/107929679