Easy
Find the Minimum Element in an Array
- Time limit
- 1 s
- Memory limit
- 128 MB
- Estimated
- 15 min
- Arrays and Strings
Description
Given a non-empty array of integers, return the smallest element.
If the minimum value appears multiple times, return the value itself. Do not return its index.
For example, for [3, 1, 9, 2], the minimum element is 1.
Implement findMinimum(nums) to return the minimum integer in the array.
Constraints
1 <= nums.length <= 1000 -1000000 <= nums[i] <= 1000000
Sample cases
3Sample 1
Input
nums = [3,1,9,2]
Expected output
1
Sample 2
Input
nums = [-8,-3,-12]
Expected output
-12
Skills and languages
Concepts
- Control Flow and Data Types
Languages
- Python 3
Solve this problem
Create a free account to write, run and submit your solution.
- Write Python or Java in the browser, with your draft saved as you type
- Run your code on the examples as often as you like
- Submit to a sandboxed judge and see exactly which case failed
- Ask the AI mentor for a hint without being handed the answer