java.lang.Object
g1701_1800.s1796_second_largest_digit_in_a_string.Solution

public class Solution extends Object
1796 - Second Largest Digit in a String.<p>Easy</p> <p>Given an alphanumeric string <code>s</code>, return <em>the <strong>second largest</strong> numerical digit that appears in</em> <code>s</code><em>, or</em> <code>-1</code> <em>if it does not exist</em>.</p> <p>An <strong>alphanumeric</strong> string is a string consisting of lowercase English letters and digits.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;dfa12321afd&rdquo;</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> The digits that appear in s are [1, 2, 3]. The second largest digit is 2.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;abc1111&rdquo;</p> <p><strong>Output:</strong> -1</p> <p><strong>Explanation:</strong> The digits that appear in s are [1]. There is no second largest digit.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 500</code></li> <li><code>s</code> consists of only lowercase English letters and/or digits.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • secondHighest

      public int secondHighest(String s)