2023 HUAWEI OD machine test real questions Python implementation [minimum number]

 Table of contents

topic

train of thought

test center

Code


topic

Given an integer array, please select 3 elements from the array to form the minimum number and output it (if the length of the array is less than 3, select all elements in the array to form the minimum number).

Input description:
A line of integer arrays separated by comma-separated string records, 0 < array length <= 100, 0 < integer value range <= 10000.

Output description:
The minimum number composed of 3 elements, if the length of the array is less than 3, select all the elements in the array to form the minimum number.

Example 1:
Input
21, 30, 62 , 5, 31
and output
21305 ,
indicating that
the length of the array exceeds 3, and you need to select 3 elements to form the smallest number. 21305 is a number composed of 21, 30, and 5 elements, which is the smallest among all combinations number

Example 2:
Input
5, 21
, output
215
Explanation
The length of the array is less than 3, select all elements

Guess you like

Origin blog.csdn.net/misayaaaaa/article/details/131926754