cpp implementation of Edit Distance