π
Find Minimum
Find Minimumμ¬μ λ°°μ΄ +10pts
Problem
Write a function that returns the smallest number in an array.
Examples
Input:
findMin([3, 1, 4, 1, 5])Output:
1Explanation
μ΄ λ¬Έμ λ **Math.min()**κ³Ό **μ€νλ λ μ°μ°μ**λ₯Ό μ¬μ©νμ¬ λ°°μ΄μμ μ΅μκ°μ μ°Ύλ λ°©λ²μ νμ΅ν©λλ€. **Math.min() ν¨μ** Math.min()μ μ λ¬λ μΈμλ€ μ€ κ°μ₯ μμ κ°μ λ°νν©λλ€: `Math.min(3, 1, 4)` β 1 **μ€νλ λ μ°μ°μ (...)** λ°°μ΄μ κ°λ³ μΈμλ‘ νΌμ³μ€λλ€: `Math.min(...[3, 1, 4])`λ `Math.min(3, 1, 4)`μ κ°μ΅λλ€. **μμ λ°°μ΄ μ²λ¦¬** [-5, -1, -10]μμ -10μ΄ κ°μ₯ μμ΅λλ€. Math.minμ μμλ μ¬λ°λ₯΄κ² ...
View detailed explanation βKey Concepts
Math.min() ν¨μ μ€νλ λ μ°μ°μ μ΅μκ° μκ³ λ¦¬μ¦ λ°°μ΄ νΌμΉκΈ°
Time: O(n) Space: O(n)
solution.js
Ctrl + Enter
Run tests to see results here.