回答編集履歴
3
訂正
answer
CHANGED
|
@@ -18,9 +18,7 @@
|
|
|
18
18
|
numbers.sort((x, y) -> {
|
|
19
19
|
int d = Math.abs(x) - Math.abs(y);
|
|
20
20
|
if (d != 0) return d;
|
|
21
|
-
|
|
21
|
+
return Integer.compare(y, x);
|
|
22
|
-
if (d != 0) return d;
|
|
23
|
-
return 0;
|
|
24
22
|
});
|
|
25
23
|
|
|
26
24
|
System.out.println(numbers.get(0));
|
2
訂正
answer
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
numbers.sort((x, y) -> {
|
|
19
19
|
int d = Math.abs(x) - Math.abs(y);
|
|
20
20
|
if (d != 0) return d;
|
|
21
|
-
|
|
21
|
+
d = Integer.compare(y, x);
|
|
22
|
-
if (
|
|
22
|
+
if (d != 0) return d;
|
|
23
|
-
|
|
23
|
+
return 0;
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
System.out.println(numbers.get(0));
|
1
訂正
answer
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
numbers.sort((x, y) -> {
|
|
19
19
|
int d = Math.abs(x) - Math.abs(y);
|
|
20
20
|
if (d != 0) return d;
|
|
21
|
-
d = x - y;
|
|
22
|
-
if (
|
|
21
|
+
if (x > y) return -1;
|
|
22
|
+
if (x < y) return 1;
|
|
23
23
|
return 0;
|
|
24
24
|
});
|
|
25
25
|
|