Skip to content

Commit

Permalink
LV0: add 특이한 정렬.java
Browse files Browse the repository at this point in the history
  • Loading branch information
keepitblazing committed Jun 6, 2024
1 parent da0c141 commit 0dadfb1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions LV0/특이한 정렬.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution {

public int[] solution(int[] numlist, int n) {
Arrays.sort(
numlist,
(a, b) -> {
int newA = Math.abs(a - n);
int newB = Math.abs(b - n);
if (newA == newB) {
return a - b;
}
return newA - newB;
}
);
return numlist;
}
}

0 comments on commit 0dadfb1

Please sign in to comment.