#C616. String Rearrangement with Minimum Distance

    ID: 49889 Type: Default 1000ms 256MiB

String Rearrangement with Minimum Distance

String Rearrangement with Minimum Distance

You are given a string s consisting of lowercase English letters and an integer k. The task is to determine whether it is possible to rearrange the characters of s so that the same characters are at least k distance apart.

In other words, for any two identical characters in the rearranged string, the absolute difference between their positions should be at least k.

If such a rearrangement exists, output Yes; otherwise, output No.

Note: When k = 1, any arrangement is valid.

inputFormat

The input consists of two lines. The first line contains the string s. The second line contains the integer k.

outputFormat

Output a single line containing either "Yes" if the string can be rearranged according to the rule, or "No" otherwise.## sample

aabbcc
3
Yes