Notice
Recent Posts
Recent Comments
Link
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
Tags more
Archives
Today
Total
관리 메뉴

공부블로그

1일 1코딩 [프로그래머스] 본문

IT/알고리즘

1일 1코딩 [프로그래머스]

So1_b 2022. 5. 24. 22:08

문자열 내 마음대로 정렬하기 

https://programmers.co.kr/learn/courses/30/lessons/12915

import java.util.Arrays;
class Solution {
    public String[] solution(String[] strings, int n) {
        Arrays.sort(strings); //오름차순으로 정렬
		System.out.println(Arrays.toString(strings));
		
		for(int i=0; i<strings.length-1; i++) {
            
			for(int j=strings.length-1;j>i;j--) {
                
				if(strings[j-1].charAt(n)>strings[j].charAt(n)) {
					String s=strings[j-1];
					strings[j-1]=strings[j];
					strings[j]=s;
				}
			}
		}
		return strings;
    }
}

'IT > 알고리즘' 카테고리의 다른 글

[프로그래머스] 모의고사  (0) 2022.06.11
[프로그래머스] 실패율  (0) 2022.06.02
1일 1코딩 [프로그래머스]  (0) 2022.05.20
1일 1코딩  (0) 2022.05.15
1일 1코딩  (0) 2022.05.14
Comments