Tap here to switch tabs
Problem
Submissions

Problem: Shortest Lexicographically Smallest Beautiful String

Shortest Lexicographically Smallest Beautiful String finds a shortest substring of a binary string with exactly k ones, breaking lexicographic ties, or returns an empty string when none exists.

Statement

You are given a binary string s and a positive integer k.

A substring of s is considered beautiful if it contains exactly k occurrences of the character ′1′'1'.

Return the shortest beautiful substring of s. If there are multiple shortest beautiful substrings of the same minimum length, return the lexicographically smallest one. If no beautiful substring exists, return an empty string "".

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • 1≤1 \leq k ≤\leq s.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Shortest Lexicographically Smallest Beautiful String

Shortest Lexicographically Smallest Beautiful String finds a shortest substring of a binary string with exactly k ones, breaking lexicographic ties, or returns an empty string when none exists.

Statement

You are given a binary string s and a positive integer k.

A substring of s is considered beautiful if it contains exactly k occurrences of the character ′1′'1'.

Return the shortest beautiful substring of s. If there are multiple shortest beautiful substrings of the same minimum length, return the lexicographically smallest one. If no beautiful substring exists, return an empty string "".

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • 1≤1 \leq k ≤\leq s.length