정렬 조건이 필요하다
static class Elem implements Comparable<Elem>{
@overide
public int compareTo(Elem other){
return num - other.num;
//return 음수 : 내(num)가먼저
//return 양수 : 쟤(other)가 먼저
}
}
시간복잡도 :: O(N log N)
O(N log N)
O(N log N)
O(N log N)
보장→ 따라서, primitive는 In-place, Object는 Stable 모두 평균 O(N log N)
In-place / Stable 여부를 알아야한다.
정렬 후,
정렬
| BOJ_10825, BOJ_1015, BOJ_11652, BOJ_15970