[algorithm] 조건 문자열

인철·2024년 2월 28일
0

algorithm

목록 보기
89/91
post-thumbnail

class Solution {
    public int solution(String ineq, String eq, int n, int m) {
        int answer = 0; // 결과값을 넣을 공간을 0으로 초기화
        if(ineq.equals(">")){
            if(eq.equals("=")){
                answer = n >= m ? 1 :0;
            } else if( eq.equals("!")){
                answer = n > m ? 1 : 0;
            }
        } else if(ineq.equals("<")){
            if(eq.equals("=")){
                answer = n <= m ? 1 :0;
            }
            if(eq.equals("!")){
               answer =  n < m ? 1 :0;
            }
        }
        // equals를 통하여 조건문을 이용해 풀기
        return answer;
    }
}
profile
같은글이있어도양해부탁드려요(킁킁)

0개의 댓글