User talk:Ashawley/Levenshtein distance/C++

int edit_distance(const std::string& s1, const std::string& s2) {  int* p = new int[s2.length+1]; int* q = new int[s2.length+1]; int* r;  p[0] = 0; for(int j = 1; j <= s2.length; ++j) p[j] = p[j-1] + 1; for(int i = 1; i <= s1.length; ++i) {      q[0] = p[0] + 1; for(int j = 1; j <= s2.length; ++j) {          q[j] = std::min(std::min(p[j] + 1, q[j-1] + 1),                        p[j-1] + (s1[i-1] == s2[j-1] ? 0 : 1));      }       r = p;       p = q;       q = r;     } int tmp = p[s2.length]; delete[] p;  delete[] q;   return tmp; }