Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

<< [13] Longest substring made of k distinct characters >>

Given an integer k and a string s, find the length of the longest substring that contains at most k distinct characters.

Example:

>>> coding_problem_13('abcba', 2)  # longest substring with at most 2 distinct characters is 'bcb'
3

>>> coding_problem_13('edabccccdccba', 3)  # 'bccccdccb'
9