Maximum Value of a String in an Array
The value of an alphanumeric string can be defined as:
- The numeric representation of the string in base
10, if it comprises of digits only. - The length of the string, otherwise.
Given an array strs of alphanumeric strings, return the maximum value of any string in strs.
Example 1
Input
strs = ["alic3","bob","3","4","00000"]Output
5"alic3" has value 5 by length, "bob" has value 3 by length, "3" has value 3, "4" has value 4, and "00000" has value 0, so the maximum value is 5.
Example 2
Input
strs = ["1","01","001","0001"]Output
1Each string in the array has numeric value 1, so the maximum value is 1.
Constraints
- 1 <= strs.length <= 100
- 1 <= strs[i].length <= 9
- strs[i] consists of only lowercase English letters and digits.