[Huawei OD Unified Exam B Paper | 200 points] Minimal loop subarray (C++ Java JavaScript python)

Huawei OD Online OJ:

Users who have already purchased this column, please private message the blogger to open an account and brush up questions online! ! !

Online OJ: brush the questions immediately

Question bank column: 2023 Huawei OD machine test (A volume + B volume) (C++JavaJSPy)

topic description

Given an array nums consisting of several integers, please check whether the array is composed of a certain sub-array repeatedly looped together, and please output the smallest sub-array.

enter description

The number n of elements in the input array in the first line, 1 ≤ n ≤ 100000

The second line inputs the numeric sequence nums of the array, separated by spaces, 0 ≤ nums[i] < 10

output description

Output the sequence of numbers of the smallest subarray, separated by spaces;

Remark

The array itself is its largest sub-array, which can be generated by looping once;

Example

enter

9
1 2 1 1 2 1 1 2 1

output

1 2 1

illustrate

The array [1,2,1,1,2,1,1,2,1] can be spliced ​​by the sub-array [1,2,1] repeated 3 times

Problem-solving ideas:

The problem requires finding a minimum

Guess you like

Origin blog.csdn.net/shangyanaf/article/details/132642484