java.lang.Object
g2201_2300.s2264_largest_3_same_digit_number_in_string.Solution

public class Solution extends Object
2264 - Largest 3-Same-Digit Number in String.<p>Easy</p> <p>You are given a string <code>num</code> representing a large integer. An integer is <strong>good</strong> if it meets the following conditions:</p> <ul> <li>It is a <strong>substring</strong> of <code>num</code> with length <code>3</code>.</li> <li>It consists of only one unique digit.</li> </ul> <p>Return <em>the <strong>maximum good</strong> integer as a <strong>string</strong> or an empty string</em> <code>&quot;&quot;</code> <em>if no such integer exists</em>.</p> <p>Note:</p> <ul> <li>A <strong>substring</strong> is a contiguous sequence of characters within a string.</li> <li>There may be <strong>leading zeroes</strong> in <code>num</code> or a good integer.</li> </ul> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> num = &ldquo;6<strong>777</strong>133339&rdquo;</p> <p><strong>Output:</strong> &ldquo;777&rdquo;</p> <p><strong>Explanation:</strong> There are two distinct good integers: &ldquo;777&rdquo; and &ldquo;333&rdquo;.</p> <p>&ldquo;777&rdquo; is the largest, so we return &ldquo;777&rdquo;.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> num = &ldquo;23<strong>000</strong>19&rdquo;</p> <p><strong>Output:</strong> &ldquo;000&rdquo;</p> <p><strong>Explanation:</strong> &ldquo;000&rdquo; is the only good integer.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> num = &ldquo;42352338&rdquo;</p> <p><strong>Output:</strong> &quot;&quot;</p> <p><strong>Explanation:</strong> No substring of length 3 consists of only one unique digit. Therefore, there are no good integers.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>3 <= num.length <= 1000</code></li> <li><code>num</code> only consists of digits.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • largestGoodInteger

      public String largestGoodInteger(String num)