29 April 2024 Shift 1 — Smallest Number in Array
E · easyP · Verified PYQarrays
Problem
Given an array of N integers, find the smallest element. Input: First line = N. Second line = N space-separated integers.
Example
Input
5 7 3 1 9 4
Output
1
Track minimum using a variable. Update whenever a smaller element is found. O(N) time.