educative.io

Educative

Are all the examples OK here?

In the first example 1 char is skipped in the output for K=2:

Input: "mmpp", K=2
Output: "mpmp" or "pmpm"

But in the next example 3 or more actual chars are skipped:

Input: "Programming", K=3
Output: "rgmPrgmiano" or "gmringmrPoa"

So my question is:
is the next answer for the last example is a valid one?:
“rgmrgmPiano”

Thanks.

@Design_Gurus I also don’t get what “K distance apart” exactly means here. In the first example, as @Pavlo_Koshla mentioned, you are saying that K=2 but the output shows that chars go through one.
Could you please add some clarification to this problem description?

“K distance apart” means that the character can reappear after this distance. For example, for K=2, if a character is at index “5” it can come again at index “7” or higher.