Tutte le sfide
Facile 0 risolte 0% di accettazione

Array Minimum

Find the smallest value in a list.

Return the smallest value in the list by checking each element once.

Implement array_minimum(numbers).

Input

numbers: A non-empty list of integers.

Output

Return the minimum.

Vincoli

1 ≤ length ≤ 100,000

Esempi

Esempio 1
Input:
numbers = [3, 9, 2]

Output atteso:
expected = 2
Input:
std::vector<long long> numbers = {3, 9, 2};

Output atteso:
long long expected = 2;
Input:
long[] numbers = new long[] {3, 9, 2};

Output atteso:
long expected = 2;

Spiegazione

2 is smaller than 3 and 9.

Esempio 2
Input:
numbers = [0, -5, 5]

Output atteso:
expected = -5
Input:
std::vector<long long> numbers = {0, -5, 5};

Output atteso:
long long expected = -5;
Input:
long[] numbers = new long[] {0, -5, 5};

Output atteso:
long expected = -5;

Spiegazione

-5 is the smallest.

Riferimenti

Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.

Impara dagli altri

Soluzioni della community

Nessuna soluzione pubblicata. Risolvi questa sfida per condividere la prima.