java.lang.Object
g2401_2500.s2496_maximum_value_of_a_string_in_an_array.Solution

public class Solution extends Object
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 = [&ldquo;alic3&rdquo;,&ldquo;bob&rdquo;,&ldquo;3&rdquo;,&ldquo;4&rdquo;,&ldquo;00000&rdquo;]</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong></p> <ul> <li>&ldquo;alic3&rdquo; consists of both letters and digits, so its value is its length, i.e. 5.</li> <li>&ldquo;bob&rdquo; consists only of letters, so its value is also its length, i.e. 3.</li> <li>&ldquo;3&rdquo; consists only of digits, so its value is its numeric equivalent, i.e. 3.</li> <li>&ldquo;4&rdquo; also consists only of digits, so its value is 4.</li> <li>&ldquo;00000&rdquo; consists only of digits, so its value is 0.</li> </ul> <p>Hence, the maximum value is 5, of &ldquo;alic3&rdquo;.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> strs = [&ldquo;1&rdquo;,&ldquo;01&rdquo;,&ldquo;001&rdquo;,&ldquo;0001&rdquo;]</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 Details

    • Solution

      public Solution()
  • Method Details

    • maximumValue

      public int maximumValue(String[] strs)