[Huawei OD machine test real questions] the longest distance of building blocks (building block game 1 with the same number) (python) 100% pass rate super detailed code comment code interpretation

[Huawei OD machine test real questions 2022&2023] real test catalog @click here @
[Huawei OD machine test real questions] signal transmission and reception & trial reading & @click here @
[Huawei OD machine real test questions] rent a car to ride the greenway & trial reading & @点here@

same number building blocks game 1

Knowledge point array cycle map
Time limit: 1s Space limit: 256MB Restricted language: Unlimited

Title description:

Xiaohua and Xiaowei learn math by playing building block games together.
They have lots of blocks, each block has a number on it, and the numbers on the blocks may be the same.
Xiaohua randomly takes some building blocks and arranges them in a row next to each other, and asks Xiaowei to find the
2 building blocks with the same number and the farthest position in this row of building blocks, and calculate the distance between them.
Xiaowei asks you to help me solve this problem.

Enter a description:

No.

Guess you like

Origin blog.csdn.net/weixin_45541762/article/details/130673355