πŸ“š

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: 1

Explanation

이 λ¬Έμ œλŠ” **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.