Smallest Element
EasyPractice library · +10 XPgreedyarraysiteration
Given a list of N integers, find and print the smallest integer in the list. If there are multiple occurrences of the smallest integer, print any one of them.
Input
The first line contains an integer N (1 <= N <= 1000). The second line contains N space-separated integers.
Output
Print a single integer, the smallest value in the list.
Constraints
1 <= N <= 1000 Each integer is between -1000 and 1000.
Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests
Example 1
Input
5 10 4 8 2 6
Output
2
The smallest element in the list [10, 4, 8, 2, 6] is 2.
Example 2
Input
3 -5 -2 -8
Output
-8
The smallest element in the list [-5, -2, -8] is -8.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
5 10 4 8 2 6
Example 2 input
3 -5 -2 -8