본문 바로가기

👩🏻‍💻 기술면접/알고리즘

[프로그래머스] Java 문자열 다루기 기본 Level 1

반응형

 

 

💡 나의 풀이

채점 결과
정확성: 100.0
합계: 100.0 / 100.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Solution {
  public boolean solution(String s) {
      boolean answer = false;
      
      int length = s.length();
      
      if(length == 4 || length == 6){
          answer = true;
      }
      
      for(int i = 0; i < length; i++){
          char chkint = s.charAt(i);
          if(chkint < '0' || chkint > '9'){
              answer = false;
          }
      }
      
      return answer;
  }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
반응형