Back to problems

K Smallest Substring

Algorithm · Akuna Capital · Medium

Problem You are given a binary string input_str, containing only '0' and '1', along with an integer k. Return a substring of input_str that satisfies all of the following: It contains exactly k occurrences of '1'. Among all qualifying substrings, its length is minimum. If multiple qualifying substrings have that minimum length, it is the lexicographically smallest one. An answer is guaranteed to exist. Function Description Implement getSubstring with these parameters: string…

Checking your access…