Lust3r 2024. 1. 30. 13:12
728x90

문제

https://school.programmers.co.kr/learn/courses/30/lessons/181840

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

내 답안 / 다른 사람들의 답안

import Foundation

func solution(_ num_list:[Int], _ n:Int) -> Int {
    return num_list.contains(n) ? 1 : 0
}

- contains 메서드를 사용하여 n이 num_list에 있는지 확인하고, 있으면 1, 없으면 0을 반환

 

import Foundation

func solution(_ num_list:[Int], _ n:Int) -> Int {
    return num_list.contains(n) ? 1 : 0
}

 

 

점수: +1