Module Expr Str Assign NameStore Str ClassDef bases body FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If BoolOpOr CompareLt Call NameLoad NameLoad Num CompareLt NameLoad Num body Return Num Assign NameStore Dict Assign NameStore Num Assign NameStore Num Assign SubscriptStore NameLoad Index SubscriptLoad NameLoad Index NameLoad Num Assign NameStore Num While CompareLt NameLoad Call NameLoad NameLoad body If CompareNotIn SubscriptLoad NameLoad Index NameLoad NameLoad body Assign SubscriptStore NameLoad Index SubscriptLoad NameLoad Index NameLoad Num AugAssignAdd SubscriptStore NameLoad Index SubscriptLoad NameLoad Index NameLoad Num AugAssignAdd NameStore Num While CompareGt Call NameLoad NameLoad NameLoad body AugAssignSub SubscriptStore NameLoad Index SubscriptLoad NameLoad Index NameLoad Num If CompareLtE SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad Num body Delete SubscriptDel NameLoad Index SubscriptLoad NameLoad Index NameLoad AugAssignAdd NameStore Num Assign NameStore Call NameLoad NameLoad BinOpSub NameLoad NameLoad Return NameLoad decorator_list decorator_list If CompareEq NameLoad Str body Assert CompareEq Call AttributeLoad Call NameLoad attr Str Num Num
N/A N/A 
Given a string s, find the length of the longest substring T that contains at most k distinct characters.

Example
For example, Given s = "eceba", k = 3,

T is "eceb" which its length is 4.

Challenge
O(n), n is the size of the string s.
 N/A __author__ Daniel Solution N/A N/A lengthOfLongestSubstringKDistinct N/A N/A self s k N/A N/A N/A 
        Sliding window
        :param s: A string
        :param k: An integer
        :return:
         N/A N/A N/A N/A len s 1 N/A k 1 N/A N/A 0 N/A cnt N/A N/A b 0 N/A e 1 N/A N/A cnt N/A N/A s N/A b 1 N/A maxa 1 N/A N/A e N/A len s N/A N/A N/A N/A s N/A e cnt N/A N/A N/A cnt N/A N/A s N/A e 0 N/A N/A cnt N/A N/A s N/A e 1 N/A e 1 N/A N/A N/A len cnt k N/A N/A N/A cnt N/A N/A s N/A b 1 N/A N/A N/A cnt N/A N/A s N/A b 0 N/A N/A N/A cnt N/A N/A s N/A b N/A b 1 N/A maxa N/A max maxa N/A e b N/A maxa N/A N/A N/A N/A __name__ __main__ N/A N/A N/A N/A N/A N/A Solution lengthOfLongestSubstringKDistinct eceba 3 4