Skip to content

Commit ed39e95

Browse files
authored
Update Partitioning Into Minimum Number Of Deci-Binary Numbers.java
1 parent dab0bcc commit ed39e95

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
class Solution {
22
public int minPartitions(String n) {
3-
return n.chars()
4-
.mapToObj(c -> (char) c)
5-
.mapToInt(Character::getNumericValue)
6-
.reduce(Integer::max)
7-
.orElse(0);
3+
int maxDigit = Character.getNumericValue(n.charAt(0));
4+
for (char c : n.toCharArray()) {
5+
maxDigit = Math.max(maxDigit, Character.getNumericValue(c));
6+
}
7+
return maxDigit;
88
}
99
}

0 commit comments

Comments
 (0)