Class Solution
java.lang.Object
g2201_2300.s2264_largest_3_same_digit_number_in_string.Solution
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>""</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 = “6<strong>777</strong>133339”</p>
<p><strong>Output:</strong> “777”</p>
<p><strong>Explanation:</strong> There are two distinct good integers: “777” and “333”.</p>
<p>“777” is the largest, so we return “777”.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> num = “23<strong>000</strong>19”</p>
<p><strong>Output:</strong> “000”</p>
<p><strong>Explanation:</strong> “000” is the only good integer.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> num = “42352338”</p>
<p><strong>Output:</strong> ""</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 Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
largestGoodInteger
-