v.shashenko
BAN USERThat's mine. Since BST assumes greater keys are all to the right we are diving to left subtrees and summing only right ones. This is post-order tree traversal.
- v.shashenko May 05, 2014static bool OneEditApart(string s1, string s2)
{
var i1 = 0;
var i2 = 0;
var edits = 0;
while (i1 < s1.Length && i2 < s2.Length)
{
if (s1[i1] != s2[i2])
{
edits++;
if (edits > 1)
return false;
if (s1.Length < s2.Length)
{
i2++;
}
else if (s2.Length < s1.Length)
{
i1++;
}
else
{
i1++;
i2++;
}
}
else
{
i1++;
i2++;
}
}
if (i1 < s1.Length - 1 || i2 < s2.Length - 1)
return false;
// for "cat" == "cat" case
if (edits == 0 && s1.Length == s2.Length)
return false;
return true;
}
>> one points to the start of the and...
I guess this should be "to the start of the array"
- v.shashenko May 17, 2014