-
프로그래머스 - 서울에서 김서방 찾기 [자바]Algorithms/- 프로그래머스 2022. 2. 2. 11:25
- 문제 링크 : 서울에서 김서방 찾기
정답
class Solution { public String solution(String[] seoul) { int x = 0; for(int i=0; i<seoul.length; i++){ if(seoul[i].equals("Kim")){ x = i; break; } } StringBuilder sb = new StringBuilder(); sb.append("김서방은 "); sb.append(x); sb.append("에 있다"); return sb.toString(); } }
분석
- 단순 for문
반응형