[LeetCode 159] Longest Substring with At Most K Distinct Characters Given a string S, find the length of the longest substring T that contains at most k distinct characters. Example Example 1: Example 2: Challenge O(n) time 分析 这道题在LeetCode上加锁了,在l......
A substring is a contiguous sequence of characters in a string. A stringxis lexicographically smaller than a stringyof the same length ifx[i]comes beforey[i]in alphabetic order for the first positionisuch thatx[i] != y[i]. Example 1: Input: s = "cbabc"Output: "baabc"Explanation: We...
Leetcode - Longest Substring with At Most Two Distinct Characters Given a string, find the length of the longest substring T that contains at most 2 distinct characters. For example, Given s = “eceba”, T is "ece" which its length is 3. [分析] 滑动窗......
1466.reorder_routes_to_make_all_paths_lead_to_the_city_zero 1493.longest_subarray_of_1_after_deleting_one_element 15.3sum 151.reverse_word_in_string 1544.make_the_string_great 1561.maximum_number_of_coins_you_can_get 159.longest_substring_with_at_most_two_distinct_...
LeetCode - Sort Characters By Frequency 解法一: 解法二: 解法三: 解法一、二,一个是用priority_queue, 另一个是sort,都是O(N logN),解法三用了桶排序,只需要O(N) Error ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer ......