# String Conversion

Moderate
0/80
Average time to solve is 15m
Contributed by

## Problem statement

You have given two strings 'A' and ‘B’ of length ‘N’ each which only consists of lowercase English letters. You have also given an integer ‘K’.

Your task is to determine if it is possible to convert string ‘A’ into ‘B’ after performing two types of operations on it:

``````1. Choose an index i (1 <= i <= N - 1) and swap A[i] and A[i+1].
2. Choose an index i (1 <= i <= N - K + 1) and if A[i], A[i+1],. . . . , A[i+K-1] all are equal to some character x (x != ‘z’), then you can replace each one with the next character (x + 1) , i.e. ‘a’ is replaced by ‘b’, ‘b’ is replaced by ‘c’ and so on.
``````

Note:

``````You are allowed to perform any operation any number of times(possibly zero) only on string 'A'.
``````
For example-
``````If the given strings are A = ‘xbbx’ and B = ‘xddx’ and K is given as 2. Then it is possible to convert string A into B by applying the second operation two times on index 2 (1 based indexing).
``````
Detailed explanation ( Input/output format, Notes, Images )
Constraints:
``````1 <= T <= 100
1 <= N <= 5000
1 <= K <= N

Time Limit: 1 sec
``````
##### Sample Input 1:
``````1
6 2
cccffc
eeeegg
``````
##### Sample output 1:
``````Yes
``````
##### Explanation of Sample output 1:
``````It is possible to convert the string ‘cccffc’ into ‘eeeegg’. Firstly, apply operation 1 on index 5 (‘cccfcf’). Then operation 1 on index 4 (‘ccccff’). Finally, apply operation 2 on index 5 (‘ccccgg’).
``````
##### Sample Input 2:
``````2
4 3
aaaa
aaaa
3 3
abc
bcd
``````
##### Sample output 2:
``````Yes
No
``````
Console