-
카테고리
-
세부 분야
알고리즘 · 자료구조
-
해결 여부
미해결
map 과 filter 함수를 써봤는데, 이렇게 하면 효율적이지 않은가요?
23.02.24 18:09 작성 조회수 261
0
for 문 돌리는게, method 돌리는것보다 빠르다고 하는데,
method 들로만 사용하여 풀면 효율적이지 않은건가요?
아래 코드로 진행해도 괜찮을까요?
function solution(s){
let answer=""
const lengths = s.map(str => str.length)
const max = Math.max(...lengths)
answer= s.filter(str => str.length === max).join('')
return answer;
}
답변을 작성해보세요.
0
답변 1