Files
PAT/source/html/t1020.html
T

17 lines
2.2 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Delete At Most Two Characters
<div class="ques-view"><p>Given a string which contains only lower case English letters, how many different strings you can get after deleting <strong>AT MOST TWO</strong> characters in it?</p>
<h3 id="input-specification-">Input Specification:</h3>
<p>Each input file contains one test case, which gives the string whose length is in <span class="katex"><span class="katex-mathml"><math><mrow><mo>[</mo><mn>3</mn><mo separator="true">,</mo><mn>1</mn><msup><mn>0</mn><mn>6</mn></msup><mo>]</mo></mrow>[3, 10^6]</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.8141079999999999em;"></span><span class="strut bottom" style="height:1.064108em;vertical-align:-0.25em;"></span><span class="base textstyle uncramped"><span class="mopen">[</span><span class="mord mathrm">3</span><span class="mpunct">,</span><span class="mord mathrm">1</span><span class="mord"><span class="mord mathrm">0</span><span class="msupsub"><span class="vlist"><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">6</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span>​</span></span></span></span><span class="mclose">]</span></span></span></span>.</p>
<h3 id="output-specification-">Output Specification:</h3>
<p>Print in a line the number of different strings you can get after deleting at most 2 characters.</p>
<h3 id="sample-input-">Sample Input:</h3>
<pre><code class="lang-in">ababcc
</code></pre>
<h3 id="sample-output-">Sample Output:</h3>
<pre><code class="lang-out">15
</code></pre>
<h3 id="hint-">Hint:</h3>
<p>Deleting 0 character gets <code>ababcc</code>.</p>
<p>Deleting 1 character gets <code>babcc</code>, <code>aabcc</code>, <code>abbcc</code>, <code>abacc</code> and <code>ababc</code>. </p>
<p>Deleting 2 character gets <code>abcc</code>, <code>bbcc</code>, <code>bacc</code>, <code>babc</code>, <code>aacc</code>, <code>aabc</code>, <code>abbc</code>, <code>abac</code> and <code>abab</code>.</p>
</div>