문자열 내 마음대로 정렬하기 (프로그래머스 - Lv 1)
2023. 3. 19. 09:51
https://school.programmers.co.kr/learn/courses/30/lessons/12915
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
<코드>
import java.util.*;
class Solution {
public String[] solution(String[] strings, int n) {
String[] answer = {};
Arrays.sort(strings, new Comparator<String>(){
@Override
public int compare(String o1, String o2){
if(o1.charAt(n) > o2.charAt(n)){
return 1;
}else if(o1.charAt(n) == o2.charAt(n)){
return o1.compareTo(o2);
}else{
return -1;
}
}});
return strings;
}
}
'코테뿌수기 - java > 문제 풀기' 카테고리의 다른 글
문자열 내림차순으로 배치하기 (프로그래머스 - Lv 1) (0) | 2023.03.19 |
---|---|
스도쿠 (백준 2580번) - 백트래킹 (0) | 2023.03.07 |
N-Queen (백준 9663번) - 백트래킹 (0) | 2023.03.07 |
컴백홈 (백준 1189) - 완전탐색 (0) | 2023.03.04 |
한국이 그리울 땐 서버에 접속하지 (백준 9996번) - 문자 (0) | 2023.03.02 |