Skip to content

Commit 61eefea

Browse files
committed
Problem description for Longest Substring with At Most K Distinct Characters
1 parent 3db1f5c commit 61eefea

File tree

1 file changed

+30
-0
lines changed
  • 0340-longest-substring-with-at-most-k-distinct-characters

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
# [Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters) ![](https://img.shields.io/badge/Medium-orange)
3+
4+
<p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the length of the longest </em><span data-keyword="substring-nonempty"><em>substring</em></span><em> of</em> <code>s</code> <em>that contains at most</em> <code>k</code> <em><strong>distinct</strong> characters</em>.</p>
5+
6+
<p>&nbsp;</p>
7+
<p><strong class="example">Example 1:</strong></p>
8+
9+
<pre>
10+
<strong>Input:</strong> s = &quot;eceba&quot;, k = 2
11+
<strong>Output:</strong> 3
12+
<strong>Explanation:</strong> The substring is &quot;ece&quot; with length 3.</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> s = &quot;aa&quot;, k = 1
18+
<strong>Output:</strong> 2
19+
<strong>Explanation:</strong> The substring is &quot;aa&quot; with length 2.
20+
</pre>
21+
22+
<p>&nbsp;</p>
23+
<p><strong>Constraints:</strong></p>
24+
25+
<ul>
26+
<li><code>1 &lt;= s.length &lt;= 5 * 10<sup>4</sup></code></li>
27+
<li><code>0 &lt;= k &lt;= 50</code></li>
28+
</ul>
29+
30+

0 commit comments

Comments
 (0)