![프로그래머스 Lv.0 문자열 정렬하기 (2)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FGjizp%2FbtsDp9lQ2Ht%2F6V8QsyADafM4ogrG1uPG4k%2Fimg.png)
import java.util.*; class Solution { public String solution(String my_string) { String answer = ""; my_string = my_string.toLowerCase(); String[] strArr = my_string.split(""); Arrays.sort(strArr); for(int i = 0; i < strArr.length; i++) { answer += strArr[i]; } return answer; } }
![프로그래머스 Lv.1 자연수 뒤집어 배열로 만들기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FLyFn6%2FbtsDwFb0lG8%2FNQOrdK9fPOR38OmejoCSck%2Fimg.png)
class Solution { public int[] solution(long n) { String len = n + ""; int[] answer = new int [len.length()]; for(int i = 0 ; i < len.length(); i++) { answer[i] = (int) n % 10; n = n / 10; } return answer; } } 테스트 코드는 정상 실행 되지만 제출에서 1, 4, 13번에서 실패했다. (int) n % 10으로 작성하면 n이 long으로 주어져 있기 때문에 n의 값이 커질 때 int에서 허용할 수 있는 값을 초과할 수도 있다. 그래서 n % 10을 먼저 진행하고 int로 형변환 할 수 있도록 수정했다. class Solution { public ..
![프로그래머스 Lv.0 369 게임](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2F8J64E%2FbtsDp6vsmLD%2FqN8d1coF4WsUSW1jLUEfd1%2Fimg.png)
class Solution { public int solution(int order) { int answer = 0; String str = String.valueOf(order); for(int i = 0; i < str.length(); i++) { if(str.charAt(i) == '3' || str.charAt(i) == '6' || str.charAt(i) == '9' ) { answer++; } } return answer; } }
![프로그래머스 Lv.0 9로 나눈 나머지](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fbu8Ds1%2FbtsDqkUt98R%2FqCtojoZlqfdqUF4HLaSvU0%2Fimg.png)
class Solution { public int solution(String number) { int answer = 0; for(int i = 0; i < number.length(); i++) { answer += Integer.parseInt(number.substring(i, i+1)); } answer %= 9; return answer; } }
![프로그래머스 Lv.0 피자 나눠 먹기 (2)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcDGRy1%2FbtsDs3EbEhl%2FtY2JbeJwTJx9aIj7ZOudtK%2Fimg.png)
class Solution { public int solution(int n) { int answer = 0; if(n % 6 == 0) { answer = n / 6; } else { for(int i = 1; ;i++) { if( i % n == 0 && i % 6 == 0) { answer = i / 6; break; } } } return answer; } }