2496. Maximum Value of a String in an Array
Easy
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:
Example 2:
Constraints:
1 <= strs.length <= 100
1 <= strs[i].length <= 9
strs[i]
consists of only lowercase English letters and digits.
解題
只要有字元,使用 strconv.Atoi
就會有 error,透過這點判斷要將字串轉為 int
還是取其長度。
Last updated