Take K Of Each Character From Left And Right In Minimum Time
Take K of Each Character From Left and Right: Use sliding window technique with two pointers to find min minutes needed to take at least k of each char ('a', 'b', 'c') from left & right of string.
2516. Take K of Each Character From Left and Right Difficulty: Medium Topics: Hash Table, String, Sliding Window You are given a string s consisting of the characters 'a', 'b', and 'c' and a non-negative integer k. Each minute, you may take either the leftmost character of s, or the rightmost character of s. Return the minimum number of minutes needed for you to take at least k of each character, or return -1 if it is not possible to take k of each character. Example 1: Input: s = "aabaaaacaabc", k = 2 Output: 8 Explanation: Take three characters from the left of s. You now have two 'a' chara...