📚

Find Maximum

Find Maximum
쉬움 배열 +10pts

Problem

Write a function that returns the largest number in an array.

Examples

Input: findMax([1, 5, 3, 9, 2])
Output: 9
Input: findMax([-1, -5, -3])
Output: -1

Explanation

이 문제는 **Math.max()** 함수와 **스프레드 연산자(...)**의 조합을 학습합니다. **Math.max() 함수** Math.max()는 전달된 인수 중 가장 큰 값을 반환합니다. 하지만 배열을 직접 받지는 않습니다: - `Math.max(1, 5, 3)` → 5 (정상 동작) - `Math.max([1, 5, 3])` → NaN (배열은 직접 처리 불가) **스프레드 연산자 (...)** 스프레드 연산자는 배열을 개별 요소로 "펼쳐줍니다": - `...[1, 5, 3]`은 `1, 5, 3`과 같습니다 - `Mat...

View detailed explanation →

Key Concepts

Math.max() 함수 스프레드 연산자 (...) 배열 펼치기 최댓값 알고리즘
Time: O(n) Space: O(n)
solution.js
Ctrl + Enter
Run tests to see results here.