Playground/자바문제집

[프로그래머스] 로그인 성공?

미숫가루설탕많이 2023. 2. 5. 21:55
class Solution {
    public String solution(String[] id_pw, String[][] db) {
        String answer = "fail";
        
        for (int i = 0; i < db.length; i++) {
            if (id_pw[0].equals(db[i][0])) {
                if (id_pw[1].equals(db[i][1])) {
                    answer = "login";
                    break;
                } else {
                    answer = "wrong pw";
                    break;
                }
            }
        }
        return answer;
    }
}