Description
Given an array of alphanumeric strings strs, return the maximum value of the array. The value of a string is its numeric value if it consists only of digits, or its length otherwise.
Examples
Input:
strs = ["alic3","bob","3","4","00000"]Output:
5Explanation:
"alic3" has length 5.
Input:
strs = ["hello","123","world","456"]Output:
456Explanation:
"hello" has length 5, "123" is numeric with value 123, "world" has length 5, "456" is numeric with value 456. The maximum is 456.
Input:
strs = ["a","bb","ccc","dddd"]Output:
4Explanation:
All strings are non-numeric, so their lengths are used: "a" has length 1, "bb" has length 2, "ccc" has length 3, "dddd" has length 4. The maximum is 4.
Constraints
- •
1 ≤ strs.length ≤ 100