Tap here to switch tabs
Problem
Submissions

Problem: Shortest Lexicographically Smallest Beautiful String

med
30 min
Try to solve the Shortest Lexicographically Smallest Beautiful String problem.

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

med
30 min
Try to solve the Shortest Lexicographically Smallest Beautiful String problem.

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