Practice Smallest K-Length Subsequence With Occurrences of a Letter
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Smallest K-Length Subsequence With Occurrences of a Letter
Problem Statement
You are given a string s, an integer k, a letter letter, and an integer repetition. Return the lexicographically smallest subsequence of s of length k that has the letter letter appear at least repetition times. The test cases are generated so that the letter appears in s at least repetition times. A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters. A string a is lexicographically smaller than a string b if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b.
Source: Smallest K-Length Subsequence With Occurrences of a Letter on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "leet", k = 3, letter = "e", repetition = 1
"eet"
# Example 2
s = "leetcode", k = 4, letter = "e", repetition = 2
"ecde"
# Example 3
s = "bb", k = 2, letter = "b", repetition = 2
"bb"
Constraints
Related LeetCode Problems
Practice more problems similar to Smallest K-Length Subsequence With Occurrences of a Letter.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.