[프로그래머스] Lv.0 첫 번째로 나오는 음수.java

hgghfgf·2023년 5월 1일
0

프로그래머스

목록 보기
14/227

첫 번째로 나오는 음수.java

class Solution {
    public int solution(int[] num_list) {
        int answer = -1;
        for(int i=0; i<num_list.length; i++){
            if(num_list[i]<0){
                answer = i;
                break;
            }
        }
        return answer;
    }
}

출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges

0개의 댓글