Class Solution
java.lang.Object
g2401_2500.s2496_maximum_value_of_a_string_in_an_array.Solution
2496 - Maximum Value of a String in an Array.<p>Easy</p>
<p>The <strong>value</strong> of an alphanumeric string can be defined as:</p>
<ul>
<li>The <strong>numeric</strong> representation of the string in base <code>10</code>, if it comprises of digits <strong>only</strong>.</li>
<li>The <strong>length</strong> of the string, otherwise.</li>
</ul>
<p>Given an array <code>strs</code> of alphanumeric strings, return <em>the <strong>maximum value</strong> of any string in</em> <code>strs</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> strs = [“alic3”,“bob”,“3”,“4”,“00000”]</p>
<p><strong>Output:</strong> 5</p>
<p><strong>Explanation:</strong></p>
<ul>
<li>“alic3” consists of both letters and digits, so its value is its length, i.e. 5.</li>
<li>“bob” consists only of letters, so its value is also its length, i.e. 3.</li>
<li>“3” consists only of digits, so its value is its numeric equivalent, i.e. 3.</li>
<li>“4” also consists only of digits, so its value is 4.</li>
<li>“00000” consists only of digits, so its value is 0.</li>
</ul>
<p>Hence, the maximum value is 5, of “alic3”.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> strs = [“1”,“01”,“001”,“0001”]</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong> Each string in the array has value 1. Hence, we return 1.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= strs.length <= 100</code></li>
<li><code>1 <= strs[i].length <= 9</code></li>
<li><code>strs[i]</code> consists of only lowercase English letters and digits.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
maximumValue
-