Skip to content

Commit 37e5ed9

Browse files
committed
refactor(lcof): simplify string joining in problem 45 Java solution
1 parent 2a49924 commit 37e5ed9

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

lcof/面试题45. 把数组排成最小的数/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ class Solution {
7777
return Arrays.stream(nums)
7878
.mapToObj(String::valueOf)
7979
.sorted((a, b) -> (a + b).compareTo(b + a))
80-
.reduce((a, b) -> a + b)
81-
.orElse("");
80+
.collect(Collectors.joining());
8281
}
8382
}
8483
```

lcof/面试题45. 把数组排成最小的数/Solution.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ public String minNumber(int[] nums) {
33
return Arrays.stream(nums)
44
.mapToObj(String::valueOf)
55
.sorted((a, b) -> (a + b).compareTo(b + a))
6-
.reduce((a, b) -> a + b)
7-
.orElse("");
6+
.collect(Collectors.joining());
87
}
9-
}
8+
}

0 commit comments

Comments
 (0)