The Meituan interviewer gave me a two-hour time limit and asked me to answer these questions!

Meituan’s questions are moderately difficult (compared to Ali). There are simple questions and difficult questions, and some special circumstances need to be considered.
However, the answering time is limited. If you do not prepare, it is still difficult to be asked these questions on the spot.

In addition, I have collected more than 20 years of company interview knowledge points, as well as various Java core knowledge points to share with you for free. If you want information, please click here to sign qf.
Insert picture description here

first question:

  • Topic:
    There are n students taking part in the final exam of a school, and there are m subjects in the exam. The school will issue awards for outstanding performance in a single subject to some students. The condition that the winners need to meet is that the score of a certain subject is the highest or one of the highest among all students. May I ask how many students should the school give awards for excellence in individual subjects?

Input: The
first line of input contains two positive integers n and m, which represent the number of students and the number of test subjects respectively. (n,m<=500)
There are next n lines, each line has m positive integers, and each positive integer is between 1-100, separated by a space, indicating the score of each student's m subject examination.

Output: The
output contains only an integer, which represents the number of people who have won the award for excellence in a single subject

Input:
5 5
28 35 38 10 19
4 76 72 38 86
96 80 81 17 10
70 64 86 85 10
1 93 19 34 41

Output: 4

The second question:

  • Title description:
    There is such a piece of pseudo code
    input a,b,m,x
    while true:
    x=(a*x+b)%m
    print(x)
    end while
    output x is in the sense of modulo, so it will There is a loop.
    For example, when a=2, b=1, m=5, x=2, the output sequence will be as follows:
    0,1,3,2,0,1,3,2,0,1,3,2 …
    Among them: 0,1,3,2 is called the shortest cycle section.
    Now given the values ​​of a, b, m, and x, please calculate the length of the shortest loop section.

Input
Input 4 numbers, a, b, m, x

Output
Output a number, the length of the shortest loop section

Sample input
2 1 5 2

Sample output
4

Prompt
1≤a,b,x≤m≤100000,a,b,x,m are all positive integers

The third question:

  • Title description:
    Number pairs are an important concept in mathematics, similar to pairs in computers. The properties of number pairs are as follows:
    each number pair (x, y) contains two real number elements x, y, describing the relationship between a pair of numbers Relationship. Comparing the size of two numbers will first compare the size of the first number, if they are the same, then compare the size of the second number.
    Now, there are n numbers (the pair may be the same), and they will form n^2 number pairs (you and yourself will also form a number pair). We want to know which number is the k-th smallest pair, and output this pair.

Input The
first line contains two numbers n, k, the meaning is as shown in the title. The
next line is n integers separated by spaces.

Output
Output the k-th smallest pair. The format is (x,y), where x is the first number in the pair, and y is the second number in the pair

Sample input
3 4
3 1 2

Sample output
(2,1)

Prompt
n≤100000,1≤k≤n^2, these n numbers are in the range of int[-2147483648,2147483647]


There are 9 pairs of sample interpretation numbers, which are: (3,3)(3,1)(3,2)(1,3)(1,1)(1,2)(2,3)(2 ,1)(2,2)
sorted from small to large: (1,1)(1,2)(1,3)(2,1)(2,2)(2,3)(3,1 )(3,2)(3,3)
The fourth is (2,1)

Fourth question:

  • Title description:
    The pseudo-median of n numbers is defined as the number ⌊(n+1)/2⌋ after sorting from small to large. Among them, ⌊x⌋ means x is rounded down.
    Now, given you n numbers, you need to add the least number to them so that k becomes the pseudo-median of the last set of numbers.
    May I ask the minimum number you need to add.

Input The
first line of input contains two numbers n, k, which means the original number and the final pseudo-median.
The next line of n numbers a_i, separated by spaces, represents the original number.
1≤n≤500,1≤a_i≤100000

Output To
output a number, you need to add the minimum number of numbers.

Sample input
4 2
2 3 3 3

Sample output
2

Tip
Sample explanation: After adding 1,1, the original array becomes 1,1,2,3,3,3, and its pseudo median is 2.

Question 5:

  • Problem description:
    Now there are two strings S and T. You need to take a substring from S and a subsequence from T to make the two strings the same. How many such different programs are there? The answer is modulo 10^9+7. Substring means to intercept a continuous segment in a string, for example, bc is a substring of abcd.
    Subsequence means to intercept several segments (or one segment) that are not necessarily consecutive in a string, for example, ac is a subsequence of abcd.
    Note that in this question, the positions of the two methods are different, but the case where the extracted character string is the same is counted as two different cases. See the sample explanation for details.

Input The
input contains two strings S, T and one string per line
|S|,|T|≤5000
Output The
output contains a number, which represents the answer modulo 10^9+7.

Sample input
aaa
aaa

Sample output
16

Hint The
example explains that S has 6 substrings and T has 7 subsequences. 6 sub-strings of S: a(1), a(2), a(3), aa(12), aa(23), aaa(123);
7 sub-sequences of T: a(1), a(2 ), a(3), aa(12), aa(23), aa(13), aaa(123); it
can be known that if the same string is a, there are 3×3 ways to choose, if this is the same If the string is aa, there are 2×3 ways. If the same string is aaa, there are 1×1 ways.
There are 16 ways in total.

Guess you like

Origin blog.csdn.net/w1103576/article/details/109264433