problem340

package
v1.6.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 0 Imported by: 0

README

< Previous                  Next >

340. Longest Substring with At Most K Distinct Characters (Medium)

Given a string, find the length of the longest substring T that contains at most k distinct characters.

Example 1:

Input: s = "eceba", k = 2
Output: 3
Explanation: T is "ece" which its length is 3.

Example 2:

Input: s = "aa", k = 1
Output: 2
Explanation: T is "aa" which its length is 2.

[Hash Table] [Two Pointers] [String] [Sliding Window]

Similar Questions

  1. Longest Substring Without Repeating Characters (Medium)
  2. Longest Substring with At Most Two Distinct Characters (Medium)
  3. Longest Repeating Character Replacement (Medium)
  4. Subarrays with K Different Integers (Hard)
  5. Max Consecutive Ones III (Medium)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL