using
System;
class
GFG
{
static
int
min(
int
x,
int
y,
int
z)
{
return
Math.Min(Math.Min(x, y), z);
}
static
int
editDistDP(
string
str1,
string
str2,
int
m,
int
n)
{
int
[,]dp =
new
int
[m + 1, n + 1];
for
(
int
i = 0; i <= m; i++)
{
for
(
int
j = 0; j <= n; j++)
{
if
(i == 0)
dp[i, j] = j;
else
if
(j == 0)
dp[i, j] = i;
else
if
(str1[i - 1] == str2[j - 1])
dp[i, j] = dp[i - 1,j - 1];
else
dp[i, j] = 1 + min(dp[i, j - 1],
dp[i - 1, j],
dp[i - 1, j - 1]);
}
}
return
dp[m, n];
}
static
bool
areKDistant(
string
str1,
string
str2,
int
k)
{
int
m = str1.Length;
int
n = str2.Length;
if
(Math.Abs(m - n) > k)
return
false
;
return
(editDistDP(str1, str2, m, n) <= k);
}
public
static
void
Main ()
{
string
str1 =
"geek"
;
string
str2 =
"gks"
;
int
k = 3;
if
(areKDistant(str1, str2, k))
Console.WriteLine(
"Yes"
);
else
Console.WriteLine(
"No"
);
}
}