Skip to content

Commit e274ecf

Browse files
authored
Create Maximum Value of a String in an Array.java
1 parent 6b41331 commit e274ecf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int maximumValue(String[] strs) {
3+
return Arrays.stream(strs)
4+
.mapToInt(Solution::getStringValue)
5+
.max()
6+
.orElse(0);
7+
}
8+
9+
private static int getStringValue(String s) {
10+
for (char c : s.toCharArray()) {
11+
if (!Character.isDigit(c)) {
12+
return s.length();
13+
}
14+
}
15+
return Integer.parseInt(s);
16+
}
17+
}

0 commit comments

Comments
 (0)