Class Solution
java.lang.Object
g2201_2300.s2259_remove_digit_from_number_to_maximize_result.Solution
2259 - Remove Digit From Number to Maximize Result.<p>Easy</p>
<p>You are given a string <code>number</code> representing a <strong>positive integer</strong> and a character <code>digit</code>.</p>
<p>Return <em>the resulting string after removing <strong>exactly one occurrence</strong> of</em> <code>digit</code> <em>from</em> <code>number</code> <em>such that the value of the resulting string in <strong>decimal</strong> form is <strong>maximized</strong></em>. The test cases are generated such that <code>digit</code> occurs at least once in <code>number</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> number = “123”, digit = “3”</p>
<p><strong>Output:</strong> “12”</p>
<p><strong>Explanation:</strong> There is only one ‘3’ in “123”. After removing ‘3’, the result is “12”.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> number = “1231”, digit = “1”</p>
<p><strong>Output:</strong> “231”</p>
<p><strong>Explanation:</strong> We can remove the first ‘1’ to get “231” or remove the second ‘1’ to get “123”.</p>
<p>Since 231 > 123, we return “231”.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> number = “551”, digit = “5”</p>
<p><strong>Output:</strong> “51”</p>
<p><strong>Explanation:</strong> We can remove either the first or second ‘5’ from “551”.</p>
<p>Both result in the string “51”.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 <= number.length <= 100</code></li>
<li><code>number</code> consists of digits from <code>'1'</code> to <code>'9'</code>.</li>
<li><code>digit</code> is a digit from <code>'1'</code> to <code>'9'</code>.</li>
<li><code>digit</code> occurs at least once in <code>number</code>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
removeDigit
-