슈콩

COS PRO 1급 JAVA 비밀번호 검사 본문

카테고리 없음

COS PRO 1급 JAVA 비밀번호 검사

shukong 2025. 12. 11. 23:41

 

 

[소스 코드]

class Main {
    public boolean solution(String password) {
			
        int length = password.length();
        for(int i = 0; i < length - 2; ++i){
            int firstCheck = password.charAt(i) - password.charAt(i+1);
            int secondCheck = password.charAt(i+1) - password.charAt(i+2);
            if(firstCheck == secondCheck && (firstCheck == 1 || firstCheck == -1))
                return false;
        }
        return true;
    }
}