cswork / OA打开练习工作台

Wells FargoOA #5

Get Substring

估计中等可在线判题

考点(AI 标注)双指针滑窗字符串

In a string containing only 0/1, find a substring with exactly k 1s; first minimize the length, and among equal lengths take the lexicographically smallest. The statement guarantees an answer exists.

输入格式

The first line is the binary string s; the second line is k. Source range: 1≤k≤|s|≤1000, and s contains at least k 1s.

输出格式

Output the chosen substring (without quotes).

样例 1

输入:

0101101
3

输出:

1011

样例 2

输入:

101
1

输出:

1

样例 3

输入:

1011
2

输出:

11