NeetCode #252LC-2516MediumSliding Window
← Back to All Problems

#252 · #2516 · Take K of Each Character From Left and Right(每种字符至少取 K 个)

📌 Problem Statement & Constraints

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 one character from either the left or the right end. Return the minimum number of minutes to take at least k of each character, or -1 if impossible. Constraints: 1 <= s.length <= 2 * 10^5, 0 <= k <= s.length.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!