Skip to content

Commit 51f7e2f

Browse files
committed
Create README - LeetHub
1 parent 8832358 commit 51f7e2f

File tree

1 file changed

+40
-0
lines changed
  • 2337-remove-digit-from-number-to-maximize-result

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<h2><a href="https://leetcode.com/problems/remove-digit-from-number-to-maximize-result">2337. Remove Digit From Number to Maximize Result</a></h2><h3>Easy</h3><hr><p>You are given a string <code>number</code> representing a <strong>positive integer</strong> and a character <code>digit</code>.</p>
2+
3+
<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>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> number = &quot;123&quot;, digit = &quot;3&quot;
10+
<strong>Output:</strong> &quot;12&quot;
11+
<strong>Explanation:</strong> There is only one &#39;3&#39; in &quot;123&quot;. After removing &#39;3&#39;, the result is &quot;12&quot;.
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> number = &quot;1231&quot;, digit = &quot;1&quot;
18+
<strong>Output:</strong> &quot;231&quot;
19+
<strong>Explanation:</strong> We can remove the first &#39;1&#39; to get &quot;231&quot; or remove the second &#39;1&#39; to get &quot;123&quot;.
20+
Since 231 &gt; 123, we return &quot;231&quot;.
21+
</pre>
22+
23+
<p><strong class="example">Example 3:</strong></p>
24+
25+
<pre>
26+
<strong>Input:</strong> number = &quot;551&quot;, digit = &quot;5&quot;
27+
<strong>Output:</strong> &quot;51&quot;
28+
<strong>Explanation:</strong> We can remove either the first or second &#39;5&#39; from &quot;551&quot;.
29+
Both result in the string &quot;51&quot;.
30+
</pre>
31+
32+
<p>&nbsp;</p>
33+
<p><strong>Constraints:</strong></p>
34+
35+
<ul>
36+
<li><code>2 &lt;= number.length &lt;= 100</code></li>
37+
<li><code>number</code> consists of digits from <code>&#39;1&#39;</code> to <code>&#39;9&#39;</code>.</li>
38+
<li><code>digit</code> is a digit from <code>&#39;1&#39;</code> to <code>&#39;9&#39;</code>.</li>
39+
<li><code>digit</code> occurs at least once in <code>number</code>.</li>
40+
</ul>

0 commit comments

Comments
 (0)