Available question text
Given a string of 'a', 'b', 'c' and integer k, compute the minimum number of characters you must take from the ends to collect at least k of each letter (or -1 if any letter appears < k). Key insight: if totals suffice, this reduces to finding the longest contiguous middle substring whose counts of each letter are ≤ total - k, which can be found with a two-pointer/sliding-window scan.
Related questions
Continue with questions that share topics or the same question type.
- Given an array nums and a sliding window of size k moving from the very left to the very right, return the maximum value in the window for each position. Solve in O(n) time using a deque.
Coding
- Extract Kth Character From The Rope Tree
Coding
- Find the Left and Right Side View of a Binary Search Tree
Coding
- Left and Right Sum Differences
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2516. Take K of Each Character From Left and Right
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source