Skip to content

Commit 467d9d0

Browse files
Added README.md file for Maximum Substrings With Distinct Start
1 parent 8ee6b2f commit 467d9d0

File tree

1 file changed

+57
-0
lines changed
  • 4087-maximum-substrings-with-distinct-start

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<h2><a href="https://leetcode.com/problems/maximum-substrings-with-distinct-start">Maximum Substrings With Distinct Start</a></h2> <img src='https://img.shields.io/badge/Difficulty-Medium-orange' alt='Difficulty: Medium' /><hr><p>You are given a string <code>s</code> consisting of lowercase English letters.</p>
2+
3+
<p>Return an integer denoting the <strong>maximum</strong> number of <span data-keyword="substring-nonempty">substrings</span> you can split <code>s</code> into such that each <strong>substring</strong> starts with a <strong>distinct</strong> character (i.e., no two substrings start with the same character).</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<div class="example-block">
9+
<p><strong>Input:</strong> <span class="example-io">s = &quot;abab&quot;</span></p>
10+
11+
<p><strong>Output:</strong> <span class="example-io">2</span></p>
12+
13+
<p><strong>Explanation:</strong></p>
14+
15+
<ul>
16+
<li>Split <code>&quot;abab&quot;</code> into <code>&quot;a&quot;</code> and <code>&quot;bab&quot;</code>.</li>
17+
<li>Each substring starts with a distinct character i.e <code>&#39;a&#39;</code> and <code>&#39;b&#39;</code>. Thus, the answer is 2.</li>
18+
</ul>
19+
</div>
20+
21+
<p><strong class="example">Example 2:</strong></p>
22+
23+
<div class="example-block">
24+
<p><strong>Input:</strong> <span class="example-io">s = &quot;abcd&quot;</span></p>
25+
26+
<p><strong>Output:</strong> <span class="example-io">4</span></p>
27+
28+
<p><strong>Explanation:</strong></p>
29+
30+
<ul>
31+
<li>Split <code>&quot;abcd&quot;</code> into <code>&quot;a&quot;</code>, <code>&quot;b&quot;</code>, <code>&quot;c&quot;</code>, and <code>&quot;d&quot;</code>.</li>
32+
<li>Each substring starts with a distinct character. Thus, the answer is 4.</li>
33+
</ul>
34+
</div>
35+
36+
<p><strong class="example">Example 3:</strong></p>
37+
38+
<div class="example-block">
39+
<p><strong>Input:</strong> <span class="example-io">s = &quot;aaaa&quot;</span></p>
40+
41+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
42+
43+
<p><strong>Explanation:</strong></p>
44+
45+
<ul>
46+
<li>All characters in <code>&quot;aaaa&quot;</code> are <code>&#39;a&#39;</code>.</li>
47+
<li>Only one substring can start with <code>&#39;a&#39;</code>. Thus, the answer is 1.</li>
48+
</ul>
49+
</div>
50+
51+
<p>&nbsp;</p>
52+
<p><strong>Constraints:</strong></p>
53+
54+
<ul>
55+
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
56+
<li><code>s</code> consists of lowercase English letters.</li>
57+
</ul>

0 commit comments

Comments
 (0)